how to unbind and bind again

前端 未结 5 1176
野性不改
野性不改 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:16

    You need to provide a handler to the function so you can bind/unbind from it. (Also allows you to bind/unbind specific events handlers within the same event:

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

    (used from http://api.jquery.com/unbind/ )

提交回复
热议问题