Answer the question
In order to leave comments, you need to log in
jQuery: analogue of $('p').all() from prototype?
let's say there is a function
function valid(o){ ... ? true : false;}
and you need to check each element for validity
in prototype, this can be done like this
if( $('p').all(valid) ) alert('OK');<br/>
in jQuery, there is only each, which, when return false, stops the further passage through the elements,
but at the exit there is no way to check if the call was interrupted in this way,
you have to do this:
var b=true;<br/>
$('p').each(function(){<br/>
if(! ....) {b=false; return false;}<br/>
};<br/>
if(b) alert('OK');<br/>
Answer the question
In order to leave comments, you need to log in
if ($('p').is(valid))
Just keep in mind that the function should return true on failure, and not vice versa.
And so you will not be satisfied
if($('p').each(valid($(this).something))) alert ('OK') ;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question