Reputation: 58632
I have this jquery code
console.log($('#tr-' + notificationInstanceId));
return
n.fn.init [a#tr-fg, context: document, selector: "#tr-fg"]
It showed you that the select works.
Now, I want to update the 6th column of that row - so I did
$('#tr-' + notificationInstanceId).find('td').eq(6).hide;
$('#tr-' + notificationInstanceId).find('td:eq(1)').eq(6).hide;
nothing seems to work. What did I do wrong?
<tbody>
<tr>
<td>1</td>
<td>
<a href="/a/OS/iii/1?instanceId=OS&ip=1.1.1.1&port=8008&h=509A4CDB9AB2&nae=OS&nodeName=B-Z" id="tr-OS">
OS
</a>
</td>
<td>2</td>
<td>
8.4 GB
</td>
<td> NA </td>
<td class="state-OS">running</td>
<td>
</td>
</tr>
<tr>
<td>2</td>
<td>
<a href="/a/bu-uu/iii/1?instanceId=bu-uu&ip=1.1.1.1&port=8008&h=509A4CDB9AB2&nae=bu-uu&nodeName=B-Z" id="tr-bu-uu">
bu-uu
</a>
</td>
<td>0</td>
<td>
0.0 GB
</td>
<td> NA </td>
<td class="state-bu-uu">not instantiated</td>
<td>
</td>
</tr>
<tr>
<td>3</td>
<td>
<a href="/a/fg/iii/1?instanceId=fg&ip=1.1.1.1&port=8008&h=509A4CDB9AB2&nae=fg&nodeName=B-Z" id="tr-fg">
fg
</a>
</td>
<td>0</td>
<td>
0.0 GB
</td>
<td> NA </td>
<td class="state-fg">not instantiated</td>
<td>
</td>
</tr>
</tbody>
Upvotes: 0
Views: 232
Reputation: 780688
.find()
is for finding descendants of an element. The 6th column of the table is not a descendant of #tr-fortiGate
. You need to go up to the containing <tr>
, then find the desired child of that.
Using a class selector is a little better than hard-coding a column number, IMHO. It allows you to rearrange the columns without having to update the code.
$("#tr-" + notificationIsntanceId).closest("tr").children("td[class^=state-]")
Upvotes: 2