Using .one() with .live() jQuery

前端 未结 6 2044
感动是毒
感动是毒 2020-12-09 04:32

I was using the live() function:

$(\'a.remove_item\').live(\'click\',function(e) {});

I needed to change this to one()

6条回答
  •  佛祖请我去吃肉
    2020-12-09 05:02

    Try this

    $('a.remove_item').live('click', function(e) {
        if(!$(this).hasClass('clicked'))
        {
          $(this).addClass('clicked');
          alert("dd"); // this is clicked once, do something here
        }
    });​
    

提交回复
热议问题