How to overwrite jquery event handlers

后端 未结 6 2022
逝去的感伤
逝去的感伤 2020-12-13 01:31

I\'ll try to explain the problem with a simple code.

var fireClick = function() { alert(\'Wuala!!!\') };

$(\'#clickme\').click(fireclick);
$(\'#clickme\').c         


        
6条回答
  •  不思量自难忘°
    2020-12-13 01:55

    You may use the jQuery function unbind to remove the first event:

    var fireClick = function() { alert('Wuala!!!') };
    
    $('#clickme').click(fireclick);
    $('#clickme').unbind('click', fireClick); // fireClick won't fire anymore...
    $('#clickme').click(fireclick); // ...but now it will
    

提交回复
热议问题