2012-08-27 26 views
-1

我需要在網格上獲取td的文本,只有被點擊和選擇的複選框,並非全部選中。如何從點擊網格的複選框中獲取文本td?

在本例中選擇的FTP,當我點擊另一條記錄時,它應該顯示該記錄的大門。

Tks很多。

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> 

+0

顯示你的HTML .. –

回答

0

通過門你的意思是錶行港口(最後TD)?因此,像這樣

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

http://jsfiddle.net/SdPur/

+0

完美。這就是我想要做的。 Tks很多的幫助。 – BaDcereal

相關問題