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

181
Views
Object.click() isn't working for label tag

I have a data set that I loop through and make rows of checkboxes along with other data. The user should have the ability to click on the checkbox to toggle whether something else should be showing. For some reason, $('label').click() never gets called. Code:

    let i = 0;
    data.forEach((row) => {
      myTable += "<tr>" + "<td>" + `<label id="label" for=` + String(i) + `><input type="checkbox" id=` + String(i) + `><span> Not showing</span></label>` + "</td>"+ "<td>" + row.name + "</td>" + "<td>" + app.nations[row.nation] + "</td></tr>"
      $('label').click(function() {
        console.log("Clicked");
        var checked = $('input').is(':checked');
        $('span').text(checked ? ' Showing' : ' Not showing');
      });
      i += 1;
    });

Thanks!

about 4 years ago · Juan Pablo Isaza
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!