Have a table column I'm trying to expand and hide:
jQuery seems to hide the td
elements when I select it by class but not by element's name.
For example, why does:
$(".bold").hide(); // selecting by class works
$("tcol1").hide(); // select by element name does not work
Note the HTML below, the second column has the same name for all rows. How could I create this collection using the name
attribute?
<tr>
<td>data1</td>
<td name="tcol1" class="bold"> data2</td>
</tr>
<tr>
<td>data1</td>
<td name="tcol1" class="bold"> data2</td>
</tr>
<tr>
<td>data1</td>
<td name="tcol1" class="bold"> data2</td>
</tr>
You can use any attribute as selector with
[attribute_name=value]
.I've done like this and it works:
https://api.jquery.com/attribute-equals-selector/