lucasdc
lucasdc

Reputation: 1042

jQuery - Access a td inside a specific tr and table

I want to access td.EditButton inside tr.Act_Buttons inside the table TblGrid_grid_servico_2. I tried this with no success: "#TblGrid_grid_servico_2 > tbody > tr.Act_Buttons > td.EditButton"

Here is my code:

<table border="0" cellspacing="0" cellpadding="0" class="EditTable" id="TblGrid_grid_servico_2">
    <tbody>
        <tr>
            <td colspan="2">
                <hr class="ui-widget-content" style="margin:1px">
            </td>
        </tr>
        <tr id="Act_Buttons">
            <td class="navButton">
                <a href="javascript:void(0)" id="pData" class="fm-button ui-state-default ui-corner-left ui-state-disabled">
                    <span class="ui-icon ui-icon-triangle-1-w"></span>
                </a>
                <a href="javascript:void(0)" id="nData" class="fm-button ui-state-default ui-corner-right">
                    <span class="ui-icon ui-icon-triangle-1-e"></span>
                </a>
            </td>
            <td class="EditButton">
                <a href="javascript:void(0)" id="sData" class="fm-button ui-state-default ui-corner-all fm-button-icon-left">Enviar
                    <span class="ui-icon ui-icon-disk"></span>
                </a>
                <a href="javascript:void(0)" id="cData" class="fm-button ui-state-default ui-corner-all fm-button-icon-left">Cancelar
                   <span class="ui-icon ui-icon-close"></span>
                </a>
            </td>
        </tr>
    </tbody>
</table>

Upvotes: 0

Views: 764

Answers (4)

Ammar Khan
Ammar Khan

Reputation: 356

var td= $('#TblGrid_grid_servico_2 tbody').find('tr#Act_Buttons').find('td#EditButton');

// play further with the td and it's content..

Upvotes: 0

Chris Dixon
Chris Dixon

Reputation: 9167

Act_Buttons is an ID, not a class, so it should be:

#TblGrid_grid_servico_2 > tbody > tr#Act_Buttons > td.EditButton

Upvotes: 2

j08691
j08691

Reputation: 208031

Since IDs must be unique, try:

#Act_Buttons > td.EditButton

Your combination of selectors might work except for the tr.Act_Buttons. There you're targeting an element with the class of Act_Buttons when it's the ID. . matches classes, # matches IDs.

Upvotes: 2

Felix
Felix

Reputation: 38112

You need to use # instead of . to target tr id="Act_Buttons" here:

$('#TblGrid_grid_servico_2 > tbody > tr#Act_Buttons > td.EditButton')
// ----------------------------------  ^ here ------------

Upvotes: 0

Related Questions