Best way to remove an event handler in jQuery?

前端 未结 20 2365
庸人自扰
庸人自扰 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 12:05

    If you use $(document).on() to add a listener to a dynamically created element then you may have to use the following to remove it:

    // add the listener
    $(document).on('click','.element',function(){
        // stuff
    });
    
    // remove the listener
    $(document).off("click", ".element");
    
    

提交回复
热议问题