Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Hiding some table rows

I have a table with some Trs and some Tds have hidden div and other Trs have a displayed divs on click on a button I want to get all the Trs that contain hidden divs only how to do that in jQuery
I tried :

$('div[id*="addDiv"]').filter(function() {
                return $(this).css('display') !== 'none';
            }).length;

to get the length of it ang it came correct but i want to get the whole tr data
html Code :

 <table class="table">
        <thead>
            <tr>
                <th scope="col">Student Name</th>
                <th scope="col">Student Email</th>
                <th scope="col">Parent Phone</th>
                <th scope="col">Actions</th>
            </tr>
        </thead>
        <tbody>
    <tr id="tr<?php echo $en->id; ?>">
                    <td><?php echo $en->fullname; ?> </td>
                    <td><?php echo $en->email; ?></td>
                    <td id="phone<?php echo $en->id; ?>"><?php echo $parentPhone; ?></td>
                    <td>
                        <div id="addDiv<?php echo $en->id; ?>" <?php if ($parentPhone != "-") {
                                                                    echo "style='display:none;'";
                                                                } ?>><button id='add<?php echo $en->id; ?>' data-toggle='modal' class='fired2 btn btn-primary' data-toggle='addModal' data-target='#addModal' data-id='<?php echo $en->id; ?>'>Add Parent</button>
                      </div>
                        <div id="editDiv<?php echo $en->id; ?>" <?php if ($parentPhone == "-") {                                                                  echo "style='display:none;'";  } ?>>
  <button data-toggle='modal' class='btn btn-success fired' data-toggle='editModal' data-target='#editModal' data-id='<?php echo $en->id; ?>' data-fname='<?php echo $userParent->firstname; ?>' data-lname='<?php echo  $userParent->lastname; ?>' data-phone='<?php echo  $userParent->phone1; ?>' data-email='<?php echo  $userParent->email; ?>' id='edit<?php echo $en->id; ?>'>Edit Parent</button>
                            <button type='button' data-id='<?php echo $en->id; ?>' id='war<?php echo $en->id; ?>' class='btn btn-outline-warning'>Delete Parent</button>
                        </div>
                        <button type="button" data-id="<?php echo $en->id; ?>" id="dang<?php echo $en->id; ?>" class="btn btn-outline-danger">Unenrol student from the course</button>
                    </td>
</tbody>
</table>

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Without seeing your actual HTML, this is an assumption, however :has(div:hidden) should work:

let $trWithHiddenDivs = $('#yourTable tr:has(div:hidden)');
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading