I am wondering if it is possible to get a hold of a jQuery collection
inside the each function without two expressions, like this:

jQuery('p').each( function(i) {
    if (i === 0) {
        // alert the length of the expression jQuery('p')
    }
});


I could of course do this:

var els = jQuery('p');

els.each( function(i) {
    if ( i===0) {
        alert(els.length);
    }
});

But for other reasons, I'd rather do it with one expression.

Reply via email to