开发者

click event to fire just once

开发者 https://www.devze.com 2023-01-31 02:37 出处:网络
i want the click() event to fire just once. I can use the removeClass() but doesnt sou开发者_运维技巧nds good if i need it again for smthing else.

i want the click() event to fire just once. I can use the removeClass() but doesnt sou开发者_运维技巧nds good if i need it again for smthing else.

Any ideas?


You can use .one() to have an event fire just once:

$('#item').one('click', function() {
    alert("You'll never see me again!");
});
0

精彩评论

暂无评论...
验证码 换一张
取 消