如何从复选框中单击网格获取文本td?

时间:2012-08-27 14:26:41

标签: jquery select text grid html-table

我需要在网格上获取td的文本,只需要单击并选中的复选框,而不是所有选中的复选框。

在本例选择的FTP中,当我点击另一条记录时,它应显示该记录的大门。

很多。

HTML code:

<table id="grid_tabela_servicos" tabindex="1" cellspacing="0" cellpadding="0" border="0" role="grid" aria-multiselectable="true" aria-labelledby="gbox_grid_tabela_servicos" class="ui-jqgrid-btable" style="width: 382px; border-width: 1px 1px 0px 0px; ">
<tbody>
    <tr role="row" id="1" tabindex="-1" class="ui-widget-content jqgrow ui-row-ltr ui-state-highlight ui-state-hover" aria-selected="true">
        <td role="gridcell" style="text-align: center; padding: 3px; " aria-describedby="grid_tabela_servicos_cb">
            <input role="checkbox" type="checkbox" id="jqg_grid_tabela_servicos_1" class="cbox" style="font-size: 14px; ">
        </td>
        <td role="gridcell" style="padding: 3px; " title="Apache" aria-describedby="grid_tabela_servicos_idx0">Apache</td>
        <td role="gridcell" style="padding: 3px; " title="80" aria-describedby="grid_tabela_servicos_idx1">80</td>
    </tr>
    <tr role="row" id="2" tabindex="-1" class="ui-widget-content jqgrow ui-row-ltr">
        <td role="gridcell" style="text-align: center; padding: 3px; " aria-describedby="grid_tabela_servicos_cb">
            <input role="checkbox" type="checkbox" id="jqg_grid_tabela_servicos_2" class="cbox" style="font-size: 14px; ">
        </td>
        <td role="gridcell" style="padding: 3px; " title="FTP" aria-describedby="grid_tabela_servicos_idx0">FTP</td>
        <td role="gridcell" style="padding: 3px; " title="21" aria-describedby="grid_tabela_servicos_idx1">21</td>
    </tr>
    <tr role="row" id="3" tabindex="-1" class="ui-widget-content jqgrow ui-row-ltr">
        <td role="gridcell" style="text-align: center; padding: 3px; " aria-describedby="grid_tabela_servicos_cb">
            <input role="checkbox" type="checkbox" id="jqg_grid_tabela_servicos_3" class="cbox" style="font-size: 14px; ">
        </td>
        <td role="gridcell" style="padding: 3px; " title="SSH" aria-describedby="grid_tabela_servicos_idx0">SSH</td>
        <td role="gridcell" style="padding: 3px; " title="22" aria-describedby="grid_tabela_servicos_idx1">22</td>
    </tr>
    <tr role="row" id="4" tabindex="-1" class="ui-widget-content jqgrow ui-row-ltr">
        <td role="gridcell" style="text-align: center; padding: 3px; " aria-describedby="grid_tabela_servicos_cb">
            <input role="checkbox" type="checkbox" id="jqg_grid_tabela_servicos_4" class="cbox" style="font-size: 14px; ">
        </td>
        <td role="gridcell" style="padding: 3px; " title="Testeaaa" aria-describedby="grid_tabela_servicos_idx0">Testeaaa</td>
        <td role="gridcell" style="padding: 3px; " title="22;25;110" aria-describedby="grid_tabela_servicos_idx1">22;25;110</td>
    </tr>
</tbody>

1 个答案:

答案 0 :(得分:0)

在门上你的意思是表格行中的端口(最后一个td)?像这样的东西

$(this).parent().siblings().last().text();
// current clicked, parent td, siblings, last sibling, get text

http://jsfiddle.net/SdPur/