I want a mouseover event to be handled after a delay, and then be inactive until a page refresh.
This is my code thus far:
$(function() {
$("#page-flip").mouseover(function() {
$(".box").toggleClass("box-change");
$(".films").toggleClass("films-change");
$(".synopsis").toggleClass("synopsis-change");
});
});
How do I add a time delay to this and than have it inactive after being fully triggered once? Thank you 🙂
You can use
.one()to have an event handler only trigger once:Here is a demo: http://jsfiddle.net/jasper/fWakf/3/
Documentation: http://api.jquery.com/one
You could also use
.off():Here is a demo: http://jsfiddle.net/jasper/fWakf/4/
Note that
.on()is new in jQuery 1.7 and in this case is the same.bind()..off()is also new so if you’re using older than 1.7 and.bind(), then use.unbind().