关于JQ元素排除有关问题
关于JQ元素排除问题
如何一行中点击input时不执行JQ的功能,谢谢
------解决思路----------------------
//除了表头(第一行)以外所有的行添加click事件.
$("tr").first().nextAll().click(function () {
//为点击的这一行切换样式bgRed里的代码:background-color:#FF0000;
//判断td标记的背景颜色和body的背景颜色是否相同;
//if ($(this).children().css("background-color") == 'transparent' || $(this).children().css("background-color") == 'rgb(255, 255, 255)')
if ($(this).children().find("input[name*='chkId']").prop('checked')) {
//如果相同,CheckBox.checked=true;
$(this).children().find("input[name*='chkId']").prop("checked", false);
$(this).children().removeClass("bgRed");
} else {
//如果不同,CheckBox.checked=false;
$(this).children().find("input[name*='chkId']").prop("checked", true);
$(this).children().addClass("bgRed");
}
});
如何一行中点击input时不执行JQ的功能,谢谢
------解决思路----------------------
//除了表头(第一行)以外所有的行添加click事件.
$("tr").first().nextAll().click(function (e) {
if($(e.target).is('input')) return;
//为点击的这一行切换样式bgRed里的代码:background-color:#FF0000;
//判断td标记的背景颜色和body的背景颜色是否相同;
//if ($(this).children().css("background-color") == 'transparent'
------解决思路----------------------
$(this).children().css("background-color") == 'rgb(255, 255, 255)')
if ($(this).children().find("input[name*='chkId']").prop('checked')) {
//如果相同,CheckBox.checked=true;
$(this).children().find("input[name*='chkId']").prop("checked", false);
$(this).children().removeClass("bgRed");
} else {
//如果不同,CheckBox.checked=false;
$(this).children().find("input[name*='chkId']").prop("checked", true);
$(this).children().addClass("bgRed");
}
});