I have the following jQuery code (take from another question somewhere here):
$(document).ready(function(){
$("#profile_dropdown").mouseenter(function(){
clearTimeout($(this).data('timeoutId'));
$("#profile_dropdown_content").fadeIn("slow");
}).mouseleave(function(){
var someElement = $("#profile_dropdown");
var timeoutId = setTimeout(function(){
$("#profile_dropdown_content").fadeOut("slow");
}, 650);
//set the timeoutId, allowing us to clear this trigger if the mouse comes back over
someElement.data('timeoutId', timeoutId);
});
});
It works as expected, however – I can’t figure out how to keep the #profile_dropdown_content shown if the mouse is moved over it. And how to make it fadeOut if the mouse moves out of course…
Any ideas?
Nest the
#profile_dropdown_contentinside the#profile_dropdowncontainer and use the hover event.jsfiddle: http://jsfiddle.net/UsWYq/1/
JS
HTML
CSS
Option 2
Another thing you could do is CSS3 transitions: http://jsfiddle.net/Ezxm5/