tags:

views:

25

answers:

2

Hi,

how can I abort the jquery each function?

$.each(big_test_object, function(i)
{

   // some code

});

Thanks in advance!
Peter

+2  A: 

from the jquery each documentation

We can break the $.each() loop at a particular iteration by making the callback function return false. Returning non-false is the same as a continue statement in a for loop; it will skip immediately to the next iteration.

$.each(big_test_object, function(i)
{

   if(i == 'yourvalue') {
          return false;
   }

});
Tim
Thank you very much!
Peter
A: 

you should return false in your callback

cheers

Pedro Gil