Reputation: 23
I have an alert box that is triggered when users mouseover a certain area. Here is the code:
$("#contentfooter:contains(This website)").mouseover(function(){
$(".navTopItemGroup_6").slideDown("slow");
alert("You've Unlocked A Hidden Area");
});
How do I prevent this alert box from activating more than one time? i.e., When they mouseover the area once, I don't want the alert box to pop up if they mouseover it twice.
Upvotes: 0
Views: 2354
Reputation: 3339
The .one() method will work if you don't hide the content again. But if you do, then simply change your mouseover event to mouseenter.
Upvotes: 0
Reputation: 13250
Here is a sample demo
one() binds an event handler and the unbinds it on its first execution.
Upvotes: 0
Reputation: 94101
Use one()
http://api.jquery.com/one/.
$element.one('mouseover', function(){ ... })
Upvotes: 1