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

180
Views
why JavaScript Find method not finding the element inside a table

I have go a varabile called checkBox which should find the input tag inside the <td> and an attribute to it. but the find method seems not finding the input tag. does any one knows why.

$("#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

Try this:

$("#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!