[jQuery] Question about Tutorial: Find me: Using selectors and events

[jQuery] Question about Tutorial: Find me: Using selectors and events


Hello, I'm very new to jQuery and trying out some of the tutorials.
In this tutorial, http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery
there is an exercise: http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery
and I have a question about this snipped of code:
$(document).ready(function() {
$("#orderedlist li:last").hover(function() {
$(this).addClass("green");
},function(){
$(this).removeClass("green");
});
});
As described in the tutorial, this code will add and remove the green
class when the user hovers the li element, but only on the last
element in the list.
The hover works as we'd want it to: the removeClass isn't executed
until the hover ends.
My question is: Why is the execution of the removeClass delayed until
the hover ends?
I'm interested in the answer at this early stage of my learning
because I think knowing the answer will help me understand how jQuery
executes.
Thanks,
Carol