Given this html:
<ul>
<li id="1">First</li>
<li id="2">Second</li>
<li id="3">Third</li>
</ul>
And this jQuery:
var $first = $('li').eq(0),
$second = $('li').eq(1),
$third = $('li').eq(2);
$second.next($first).css('background-color','red');
Why is the third li element given the background colour of red? I expected that using the cached jQuery object ($first) as a filter would mean nothing would be found.
jsFiddle:
Thanks.
.nextonly takes a selector string as argument, so your argument is ignored and is effectively the same as:Relevant part from source where non selector string filters are ignored: