nameli...">

Hide item in the first row of the table

I have the following table

<table id="mytable"> <tr> <td>name</td> <td> <a id="button1" class="button">link</a> </td> </tr> <tr> <td>name2</td> <td> <a id="button2" class="button">link</a> </td> </tr> </table> 

I want to hide the first row of the first column using jQuery, but I'm not sure how to do it, but I managed to do the following (to make the first tr-font italic)

 $(document).ready(function() { $("#mytable tr:first").css("font-style", "italic"); }); 

can anyone help me hide the first button of the first row

early

amuses

+4
source share
2 answers

Since you have an id button, you can use an identifier to hide it.

 $('#button1').hide(); 

If you want to use class and for some reason cannot use id, you can use the find () method to find an element within the descendants that fulfills the given selection criteria.

Live demo

 $(document).ready(function() { $("#mytable tr:first").find('.button').hide(); }); 
+8
source

use this code

  <script> $(document).ready(function() { $("#mytable tr:first #button1").css("display", "none"); }); </script> 
+1
source

All Articles