search

Home  >  Q&A  >  body text

javascript - jQuery event binding on usage

$("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. . .

淡淡烟草味淡淡烟草味2819 days ago440

reply all(2)I'll reply

  • 巴扎黑

    巴扎黑2017-05-19 10:35:20

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

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-05-19 10:35:20

    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的
     })

    reply
    0
  • Cancelreply