hi
$("span:last-child").hide("fast", function () {
$(this).prev().hide("fast", arguments.callee);
});
I can't understand this point in OVERHEAD code:
1) ("span:last-child") : what is this?
2) arguments.callee : what is this?
hi
$("span:last-child").hide("fast", function () {
$(this).prev().hide("fast", arguments.callee);
});
I can't understand this point in OVERHEAD code:
1) ("span:last-child") : what is this?
2) arguments.callee : what is this?
("span:last-child")
Returns all the span elements that are the last child of their parent. The arguments.callee looks like its trying to pass the function itself to the next function. Essentially its passing a function pointer. It looks like what it does is find the span object and then recursively hides all the prior siblings.
span:last-child
selects the last child element in every span.
arguments.callee
is a reference to the function it's called in, even works for unnamed functions.
$
is the main jQuery function.
$("span:last-child")
searches for any <span>
tags that are the last child of their parent.
Finds:
<div><span>some data </span> something else <span>testing</span></div>
It would find the span that includes testing
but not the some data
.
It then hides those spans it found. The second argument to hide is a callback after the animation. That callback goes to the "previous" child (the 'something else' text node), hiding it and passing the "called function" (arguments.callee) as the callback. Which makes this a "recursive" function.
This would hide the entire contents of all blocks that have a <span>
as their last child.
("span:last-child") will match the a span the is the last child of it's parent.
arguments.callee is a reference to the 'actual' function being called. In this instance is would just be assinging the same hide function to the most previous sibling. In effect creating a 'new' last span.