Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery Hide table rows

Tags:

jquery

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

like image 351
tomasz Avatar asked May 22 '10 17:05

tomasz


People also ask

How to hide a table row in jQuery?

Use . hide() method of jQuery to hide it as you just need to hide it.

How to hide and show table row in jQuery?

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.

How do I hide TR if TD is empty?

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().


2 Answers

this might work for you...

$('.trhideclass1').hide(); 

 

<tr class="trhideclass1">   <td>Label</td>   <td>InputFile</td> </tr> 
like image 141
Derek Avatar answered Sep 28 '22 00:09

Derek


You just need to traverse up the DOM tree to the nearest <tr> like so...

$("#ID_OF_ELEMENT").parents("tr").hide(); 

jQuery API Reference

like image 42
Josh Stodola Avatar answered Sep 27 '22 22:09

Josh Stodola