I am hiding a bunch of textboxes and it works fine, the problem is, the textboxes are in a table, so I also need to hide the corresponding labels. the structure is something like this
<tr> <td> Label </td> <td> InputFile </td> </tr>
in fact its just easier if I hide the rows that have a fileinput , can someone help please
Use . hide() method of jQuery to hide it as you just need to hide it.
In the click event of button, tr:odd selector is used with table class to hide the rows. You may simply use “tr:odd” as well, however, this will hide all tables odd rows in the web page. }); Again tr:odd selector with table class is used in the show jQuery method.
To hide table rows, iterate through all the td element and check it's text. If it is empty then hide it's parent (which is tr) using . hide().
this might work for you...
$('.trhideclass1').hide();
<tr class="trhideclass1"> <td>Label</td> <td>InputFile</td> </tr>
You just need to traverse up the DOM tree to the nearest <tr>
like so...
$("#ID_OF_ELEMENT").parents("tr").hide();
jQuery API Reference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With