[英]Unable to Click a row and call javascript function?
我无法触发$(this).toggleClass('selected');
用于内容表。 当我调试它时,请跳过此事件。 如何确定其被选中?
$('#contentChangesTable tr')
.filter(':has(:checkbox:checked)')
.addClass('selected')
.end()
.click(function (event) {
$(this).toggleClass('selected');
if (event.target.type !== 'checkbox') {
$(':checkbox', this).attr('checked', function () {
return !this.checked;
});
}
});
您要使用prop
而不是attr
来设置选中
$(function () {
$('#contentChangesTable tr')
.filter(':has(:checkbox:checked)')
.addClass('selected')
.end()
.click(function (event) {
$(this).toggleClass('selected');
if (event.target.type !== 'checkbox') {
$(':checkbox', this).prop('checked', function () {
return !this.checked;
});
}
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.