Best way to remove an event handler in jQuery?

前端 未结 20 2326
庸人自扰
庸人自扰 2020-11-21 11:38

I have an input type=\"image\". This acts like the cell notes in Microsoft Excel. If someone enters a number into the text box that this input-image

20条回答
  •  醉话见心
    2020-11-21 11:55

    In case .on() method was previously used with particular selector, like in the following example:

    $('body').on('click', '.dynamicTarget', function () {
        // Code goes here
    });
    

    Both unbind() and .off() methods are not going to work.

    However, .undelegate() method could be used to completely remove handler from the event for all elements which match the current selector:

    $("body").undelegate(".dynamicTarget", "click")
    

提交回复
热议问题