0

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?

HTML

<tbody>

    <tr>
        <td>1</td>

        <td>
            <a href="/a/OS/iii/1?instanceId=OS&amp;ip=1.1.1.1&amp;port=8008&amp;h=509A4CDB9AB2&amp;nae=OS&amp;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&amp;ip=1.1.1.1&amp;port=8008&amp;h=509A4CDB9AB2&amp;nae=bu-uu&amp;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&amp;ip=1.1.1.1&amp;port=8008&amp;h=509A4CDB9AB2&amp;nae=fg&amp;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>
9
  • 1
    Please note that the sixth column will have columnIndex === 5. Commented Jun 19, 2019 at 15:11
  • @connexo - I will try 5. Commented Jun 19, 2019 at 15:15
  • @RoryMcCrossan - Okay I will add that. Commented Jun 19, 2019 at 15:15
  • it looks like #tr-fortiGate is an <a> element, not <tr>. Can you add the HTML? Commented Jun 19, 2019 at 15:21
  • @Barmar It is an a inside a tr - Commented Jun 19, 2019 at 15:24

1 Answer 1

2

.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-]")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.