Jquery unbind events bound with one()

后端 未结 3 1078
孤独总比滥情好
孤独总比滥情好 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:46

    You unbind whatever event that is bounded with .one().

    $('your_element').unbind('event_called_with_one');
    

    $('input[type=text]').focus(function(){
        $(this).one('keypress',function(){console.info('This should not print!');});
        if($('input[type=checkbox]').prop('checked'))$(this).unbind('keypress');
    });
    
    
    

提交回复
热议问题