单击另一个td中但在同一tr中的复选框后,如何在td中找到值
本文关键字:td tr 另一个 单击 复选框 | 更新日期: 2023-09-27 18:00:28
我有一个包含几列和几行的表。当我单击每行开头的复选框时,我希望将特定单元格的值存储到变量中,并在比较其他单元格时使用它。
如何从与单击的复选框位于同一行的单元格中获取数据?
此函数由点击的复选框的点击事件调用
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;
<%}%>
}
这样的东西应该会起作用(在看不到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
});