jQuery 1.7 on() and off() methods for dynamic elements

前端 未结 3 978
误落风尘
误落风尘 2020-12-08 03:13

jQuery 1.7\'s .on() and .off() methods are supposed to replace .live() and such.

I tried it with a dynamic item:



        
3条回答
  •  太阳男子
    2020-12-08 03:26

    "Bind" with:

    $(document).on('click','.myDiv',function(){ ... });
    

    And "unbind" with:

    $(document).off('click','.myDiv');
    

提交回复
热议问题