Please reference http://docs.jquery.com/How_jQuery_Works, the
Chainability segment.

I'm confused on the given description of .end():

You can take this even further, by adding or removing elements from
the selection, modifying those elements and then reverting to the old
selection, for example:
$("a")
   .filter(".clickme")
     .click(function(){
       alert("You are now leaving the site.");
     })
   .end()

<a href="http://google.com/"; class="clickme">I give a message when you
leave</a>

Methods that modify the jQuery selection and can be undone with end(),
are the following:

add(),
children(),
eq(),
filter(),
find(),
next(),
not(),
parent(),
parents(),
siblings() and
slice().

What does reverting and undone mean here?  When I run the code, the
link click event runs the alert, I hit Ok, and it passes me to
Google.  So the words reverting and undone confuse me, as I would take
this to mean the modified click event would be "undone" and never
executed.   So what does .end() really do?  A friend thinks it could
be a chain terminator, though he never uses it.  Is it just a cleanup
thing part of good practice and not technically needed?

Thanks for educating a real jQuery beginner.

Reply via email to