I have a menu-like drop down container that hides via binding the \"mouseleave\" event.
Most renderers (all except Gecko, I think) implement opened menus and their options in a separate "window", not as elements on the page. The page is, then, not necessarily aware of the user's interaction with an open
menu. It's very unlikely that you'll be able to achieve the desired effect across all the major browsers...
Edit: ... but maybe so. This works for me in Safari and Firefox. I can't test in IE right now, but give it a shot:
var timer;
$('#container').mouseleave(function(e) {
if($(e.target).parents('#container').length) {
return;
}
timer = setTimeout(function() {
$('#container select').blur();
}, 50);
}).mouseenter(function(e) {
if(timer) {
clearTimeout(timer);
}
});
Edit 2: actually, Safari doesn't fire mouseleave
(or mouseout
) at all when the "window" is open.