This article is taken from How jQuery Works.
jQuery uses an interesting concept called a "Builder" to make its code short and simple. The Builder pattern is an object-oriented programming design pattern that has been gaining popularity.
In a nutshell: Every method within jQuery returns the query object itself, allowing you to 'chain' upon it, for example:
alert("You are now leaving the site.");
Which would work against the following HTML:
<a href="http://google.com/" class="clickme">I give a message when you leave</a>
<a href="http://yahoo.com/" class="hideme">Click me to hide!</a>
<a href="http://microsoft.com">I'm a normal link</a>
Methods that modify the jQuery selection and can be undone with end(), are the following:
Please check the Traversing API documentation for details of these methods.
Iana Tsolova is Product Manager at Telerik’s DevTools division. She joined the company back in the beginning of 2008 as a Support Officer and has since occupied various positions at Telerik, including Senior Support Officer, Team Lead at one of the ASP.NET AJAX teams and Technical Support Director. Iana’s main interests are web development, reading articles related to geography, wild nature and latest renewable energy technologies.
Copyright © 2017, Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks or appropriate markings.