Is there a way to make jQuery wait a certain about amount of time before mouseout event is fired?
It is firing too early at the moment and I’d prefer to wait 500ms before it evaluates the mouse out. An example of the code I’m using below.
$('.under-construction',this).bind({
mousemove: function(e) {
setToolTipPosition(this,e);
css({'cursor' : 'crosshair' });
},
mouseover: function() {
$c('show!');
showUnderConstruction();
},
mouseout: function() {
$c('hide!');
hideUnderConstruction();
},
click: function() {
return false;
}
});
Is there a jQuery way to do this or will I have to do it myself?
Split the logic inside the
mouseoutinto another function. in themouseouteven call this function with asetTimeout("myMouseOut", 500). And you can combine themouseoverevent with aclearTimeout()to reset the timer if the user moves into a new element.