is there a way to force event to fire only once on given element (per element, not whole document) when using live()?

前端 未结 2 1715
遥遥无期
遥遥无期 2020-12-22 12:16
$(\'div.myclass\').live(\'click\',function() {
    alert(\'i should respond only once\');
});

I know that there is a one() function wi

2条回答
  •  再見小時候
    2020-12-22 13:00

    $('div.myclass').live('click',function() {
       if($(this).attr('clicked') != 'yes')
       {
        alert('i should respond only once');
        $(this).attr('clicked', 'yes');
       }
    
    });
    

提交回复
热议问题