Jquery Remove All Event Handlers Inside Element

后端 未结 3 511
臣服心动
臣服心动 2020-12-10 00:43

I have a div element with several elements inside it like buttons and so forth which have event handlers attached to them. I know its possible to go:

$(\"#bu         


        
相关标签:
3条回答
  • 2020-12-10 01:23

    Try with

    $("#div1 >* ").off();
    

    Or:

    $("#div1").find('button').off();
    

    if you're talking about <button> elements

    0 讨论(0)
  • 2020-12-10 01:25

    jQuery will do the looping for you for just the direct children:

    $("#div1").children().off();
    

    or if you want all descendants:

    $("#div1").find("*").off();
    
    0 讨论(0)
  • 2020-12-10 01:27

    Does this help:

    $("#div1").find('*').off();
    
    0 讨论(0)
提交回复
热议问题