In August 2006, the jQuery library was first released by John Resig at http://jquery.com, as an effort to create a convenient API to locate DOM elements. Since then, it has been an integral part of a web developer's toolkit. jQuery in its core uses several Design Patterns and tries to urge their use to the developer through the methods that it provides. The Composite Pattern is one of them and it is exposed to the developer through the very core
jQuery() method, which is used for DOM traversal, one of the highlights of the jQuery library.
In this chapter, we will:
Have a refresher on DOM scripting using jQuery
Introduce the Composite Pattern
See how the Composite Pattern is used by jQuery
Introduce the Iterator Pattern
Use the Iterator Pattern in an example application