从触发的事件 jquery 中排除类

Exclude a class from fired event jquery

本文关键字:排除 jquery 事件      更新时间:2023-09-26

我有一个表,如果动态生成的输入被修改,则会触发keyup事件,但我想从事件中排除表行中的某些输入类,我尝试了两个选项,但都失败了

$(document).on('keyup', '.tg > tbody > tr:not(.pd1)', function() {});
$(document).on('keyup', '.tg > tbody > tr:not(".pd1")', function() {}); //added quotes to pd1 class

嘶嘶!

不要将事件注册到 tr,而是使用输入

$(document).on('keyup', '.tg > tbody  input:not(.pd1)', function() {});

Arun 假设类pd1在输入上,而不是像问题所暗示的那样在 tr 上。 如果类pd1tr上,则:

$(document).on('keyup', '.tg > tbody > tr:not(.pd1) input', function() {});