Is there any way to get a hover function to only execute once? This is what I'm currently trying:
$('#ask').live('hover', function() {
$('#homesearch-after').hide(300);
$.doTimeout( 300, function() {
hideClosedSearchLink();
showHomeSearch();
});
});
But that's not working. How can I only get this hover to activate once?
I've tried changing .live with .one and .bind... resulting in nothingness.
You've already answered yourself, use .one()
(not .live()
).
But as lasseespeholt just pointed out in a comment, .hover()
is shorthand for binding to mouseenter
and mouseleave
, and is not an event in itself.
Try this:
$('#ask').one('mouseenter', function() {
$('#homesearch-after').hide(300);
$.doTimeout( 300, function() {
hideClosedSearchLink();
showHomeSearch();
});
});
If that still doesn't work, try just using the good ol' .hover()
and then .unbind()
ing it immediately after it's finished.
$('#ask').hover(function() {
$('#homesearch-after').hide(300);
$.doTimeout( 300, function() {
hideClosedSearchLink();
showHomeSearch();
});
// Again taking into account what lasseespeholt said
$(this).unbind('mouseenter mouseleave')
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With