javascript - jQuery event binding on usage
淡淡烟草味
淡淡烟草味 2017-05-19 10:33:20
0
2
436
$("table td").click(function(){ /*……*/ })

This way of writing cannot handle dynamically added "td", so it is changed to the following:

$("table").on("click","td",function(){ /*……*/ })

But now we need to deal with a special one, which does not need to include a certain one:

$("table td").not($(".check")).click(function(){ /*……*/ }),

What I want to ask now is: How to write the parameters like above and what is the format. . .

淡淡烟草味
淡淡烟草味

reply all(2)
巴扎黑

$('table').on('click','td:not(.check)',handler)

仅有的幸福

In fact, if the class name of the current element obtained in the function contains .check, isn’t it enough to just do a return or other processing?

It’s early in the morning and I didn’t understand the meaning of the question clearly. If you don’t want to deal with td with check

$("table").on("click","td",function(){
    var thisObj = $(this);
    if(thisObj.hasClass('check')){
        return;
    }
    //继续处理没带check的
 })
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template