Best way to remove an event handler in jQuery?

前端 未结 20 2362
庸人自扰
庸人自扰 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:56

    To remove ALL event-handlers, this is what worked for me:

    To remove all event handlers mean to have the plain HTML structure without all the event handlers attached to the element and its child nodes. To do this, jQuery's clone() helped.

    var original, clone;
    // element with id my-div and its child nodes have some event-handlers
    original = $('#my-div');
    clone = original.clone();
    //
    original.replaceWith(clone);
    

    With this, we'll have the clone in place of the original with no event-handlers on it.

    Good Luck...

提交回复
热议问题