Is there any way to modify the order JQuery each() accesses the elements on the page?
I.e I have 4 elements on the page and I want element 3 to come first, then 2, then 4 and then 1.
Thanks
Richard
.each() will deliver the nodes the same way they appear in the DOM. But it also passes the index into the callback functions. So if you need to act differently, check the index
$('object').each(function(index) {
if( index === 2)
alert('yay');
});
Ref.: .each()