How to remove all click event handlers using jQuery?

后端 未结 5 2039
没有蜡笔的小新
没有蜡笔的小新 2020-12-01 02:18

I\'m having a problem. Basically, when a user clicks an \'Edit\' link on a page, the following Jquery code runs:

$(\"#saveBtn\").click(function () {
    save         


        
5条回答
  •  不知归路
    2020-12-01 03:15

    You would use off() to remove an event like so:

    $("#saveBtn").off("click");
    

    but this will remove all click events bound to this element. If the function with SaveQuestion is the only event bound then the above will do it. If not do the following:

    $("#saveBtn").off("click").click(function() { saveQuestion(id); });
    

提交回复
热议问题