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

188
Views
por qué el método JavaScript Find no encuentra el elemento dentro de una tabla

Tengo una variable llamada checkBox que debería encontrar la etiqueta de entrada dentro de <td> y un atributo para ella. pero el método de búsqueda parece no encontrar la etiqueta de entrada. ¿Alguien sabe por qué?

 $("#table-products tbody tr td").on('click', function () { var checkBox = $(this).find("input"); if ($(checkBox).is(':checked')) { checkBox.prop("checked", false); } else { checkBox.prop("checked",true); } });
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div class="container"> <div class="row"> <div class="col-md-12"> <div class="table-responsive"> <table class="table table-hover table-bordered" id="table-products"> <thead> <tr> <th>Product Name</th> <th>Product Categorey</th> <th>Product Price</th> <th>Product Color</th> <th></th> </tr> </thead> <tbody> <tr> <td>Iphone 4</td> <td>Mobiles</td> <td>450</td> <td>Red</td> <td><input type="checkbox" class="product-checkbox" /></td> </tr> </tbody> </table> </div> </div> </div> </div>

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Prueba esto:

 $("#table-products tbody tr td").on('click', function () { var checkBox = $(this).parents('tr').find("input"); if ($(checkBox).is(':checked')) { checkBox.prop("checked", false); } else { checkBox.prop("checked", true); } });
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!