2013-02-22 21 views
0

我有一張桌子,有幾列和幾行。當我點擊每行開頭的複選框時,我想將特定單元格的值存儲到變量中,並將其用於比較其他內容。如何在單擊另一個td中的複選框但在同一tr中的複選框時查找td內的值?

我該如何去獲取單擊複選框所在行的單元格中的數據?

這個函數獲取由該被點擊

function checkLives 
if ($('.CarrierID:contains("2")', $(':checkbox').parents('td')).length > 0) 
     { 
      //if its not dental 
      <%if (this.CurrentProduct != Products.Dental){%> 

       //if the lives being quoted are over 16 

       //Here is where I would need the value inside of that table row 
       if (livesover16) 
       { 
        //show popup 
        $('#over16').dialog('open'); 
        return false; 

      <%}%> 
     } 
+0

讓我們來看看頁面的HTML(不是生成它的服務器端代碼,實際的HTML)。 – 2013-02-22 14:11:10

回答

1

這樣的事情應該工作的複選框,單擊事件稱爲(硬更精確地說沒有看到HTML):

$('input[type="checkbox"]').on('change', function(){ 

    var tdtext = $(this) //the current clicked chexbox 
        .closest('tr') //the wrapping tr of the chechbox 
        .find('td') //find the td 
        .text(); //get the text 
}); 
相關問題