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

294
Views
how to count properly javascript, and show a div if/else?

I'm trying to count two variables, and if one is bigger than number 1 show a div, else don't show anything.

I got a column with 10 inputs, so i wanna check all inputs for the magic word, then count. I just need to show div if x it at least 1 time in one of the inputs. What I'm doing wrong?

var x = 0;
var l = 0;
for (let i = 0; i <= 10; i++) {
  $(document).on("keyup change", ".check" + i, function() {
    if ($(this).val().match(/magicword/i)) {
      l++;
    } else {
      x++;
    }
  });
}

if (x >= 1) {
  $(".nda").show();
}

is it better to use show() or toggle()? I want if user deletes magicword div to hide again.

about 4 years ago · Santiago Gelvez
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!