how to unbind and bind again

前端 未结 5 1124
野性不改
野性不改 2021-01-23 00:59
$(\"#archive\").click(function(event){
        /*do something*/
});

$(\'#archive2\').unbind(\'click\',event);

i have this click function that I unbind

5条回答
  •  一生所求
    2021-01-23 01:21

    As of jQuery 1.7 you should use on and off for all your event handler binding:

    var handler = function() {
      alert('The quick brown fox jumps over the lazy dog.');
    };
    $('#foo').on('click', handler);
    $('#foo').off('click', handler);
    

提交回复
热议问题