Is there any way to get a hover function to only execute once? This is what I\'m currently trying:
$(\'#ask\').live(\'hover\', function() {
$(\'#homesea
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')
});