Jquery unbind events bound with one()

后端 未结 3 1110
孤独总比滥情好
孤独总比滥情好 2020-12-18 22:09

Is there any method to unbind an event that has been bound with one()? Sort of like unone()

3条回答
  •  情话喂你
    2020-12-18 22:47

    Quote from JQuery.com:

    You cannot unbind a listener created using .one(). If you want to be able to unbind something that has to occur only once but still be able to unbind it before it occurs, you have to use .bind()

    Something like:

    $("#element").on("click",function(event){
        //do stuff here
        $(this).off(event);
    }
    

提交回复
热议问题