Show / hide DIV on mouse over
javascript, jquery
Solution
[reedit based on comment] jsfiddle revised, removed css-only solution. The trick is to monitor the hover state of the sliding element and use a timeout to allow the user to move over the slided element (see also comments in the updated jsfiddle).
jsfiddle derived from OPs jsfiddle @here
The hover function using your #ids:
function hover(e){
e = e || event;
var el = e.target || e.srcElement
,showel = $('#dvNotifications')
;
if (!/NotificationSummary/i.test(el.id)) {
showel .attr('data-ishovered',/over/i.test(e.type));
} else {
showel .attr('data-ishovered',false)
}
if (/true/i.test(showel .attr('data-ishovered'))){return true;}
if (/over$/i.test(e.type) && /NotificationSummary/i.test(el.id)){
showel .slideDown();
} else {
setTimeout(function(){
if (/false/i.test(showel .attr('data-ishovered'))) {
showel .slideUp();
showel .attr('data-ishovered',false);
}
}
,200);
}
}
Problem
I want to show a a DIV on image / link hover and i have written following code ``` $("#NotificationSummary").hover( function () { $("#dvNotifications").slideDown(); }, function () { $("#dvNotifications").slideUp(); } ); ``` DIV is showing on hover but when i move to div it hides, How can i stop div from hiding while mouse is over it please view the demo http://jsfiddle.net/3hqrW/15/