-1

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

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

非常感谢。

HTML 代码:

<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>

4

1 回答 1

0

门是指表格行中的端口(最后一个 td)吗?所以像这样

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

http://jsfiddle.net/SdPur/

于 2012-08-27T15:34:12.787 回答