9

how can I abort the jquery each function?

$.each(big_test_object, function(i)
{
   // some code

});
1

2 Answers 2

20

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;
   }

});
Sign up to request clarification or add additional context in comments.

Comments

2

you should return false in your callback

cheers

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.