<分区>
我想根据列中设置的标志值禁用对行的行点击 其余的行应该是可点击的,并且也在某些列之间
具有 true 的前两行应该是不可点击的。但是,其余行应该可以从第 1-5 列点击。
这是 link
最佳答案
提取行中最后一个单元格的 .text()
并测试它:
$('#table tr').find('td:gt(0):lt(5)').on("click", function() {
if ($(this).closest('tr').find('td:eq(5)').text() != "true") {
alert("hello");
}
});
http://jsfiddle.net/mblase75/mEbUG/2/
或者,您可以在调用 .on("click")
之前.filter
掉不需要的单元格:
$('#table tr').find('td:gt(0):lt(5)').filter(function() {
return ($(this).closest('tr').find('td:eq(5)').text() != "true");
}).on('click', function() {
alert("hello");
});
关于javascript - 禁用表格中的行点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12185211/
相关文章:
javascript - 如何等待所有数据加载ajax完成以在Angular中渲染页面?
Javascript ES2015 检查对象中的命名键之一是否为空
jQuery UI 可删除 : how to make it live?
html - 将鼠标悬停在其中一个元素上时,如何突出显示 tr 元素的前 2 个 td 元素?
javascript - 如何使用Nightwatch创建条件 "if element not exist - do smth"?
javascript - Google Geochart - 无法将区域设置为特定省份