Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

142
Views
jquery check if each loop was broken

You can break a jQuery.each loop by returning false from the callback function:

$('elements').each(function () {
  return false; // break
});

Is there a way to check that it was broken?

I want to break a nested loop, ideally without needing a variable to track it:

for (...) {
  $('elements').each(function () {
    return false; // break
  });
  // was the each loop broken? then break; again
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Consider the following.

var breakTest = false;
for (...) {
  $('elements').each(function () {
    if(...){
      ...
    } else {
      breakTest = true;
      return false; // break
    }
  });
  // was the each loop broken? then break; again
  if(breakTest){
    break;
  }
}

You can also do Code Blocks if you choose.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!