I got a question regarding the .hover() state. I have one navigation container id='search' and a other container called content (id='content') which is set to be hidden.
When I hover over the headline the content container shows up with links in it. But here's the question, is it possible to tell jQuery to not hide the content when I hover over it? Basically, I hover over the headline > the content shows up > so that I can click on the links and the content will disappear once I leave the headline or the content with my mouse.. Is that possible? ;/
Here's my HTML code.
<div class='navigation'>
<ul>
<li class='headline' id='search'>Search</li>
<li class='headline' id='news'>News</li>
<li class='headline' id='media'>Media</li>
<li class='headline' id='miscellaneous'>Miscellaneous</li>
</ul>
<div id='content'>Hover over a headline to show its content.</div>
</div>
And JavaScript / jQuery
$('#content').hide(); /* Hide content container */
var contentSearch = '<ul>' +
'<li><img src=\'images/icons/youtube.png\' class=\'icon\'><a class=\'link\' href=\"#\">DuckDuckGo</a></li>' +
'<li><img src=\'images/icons/youtube.png\' class=\'icon\'><a class=\'link\' href=\"#\">Google</a></li>' +
'</ul>';
$('#search').hover(function () { /* Headline is hovered upon */
var pos = $(this).position(); /* Get the position of the headline container relative to its parent */
var headlineWdth = $(this).width(); /* Get the width of the headline container */
$('#content').html(contentSearch); /* Content container gets its content filled in */
var contentWdth = $('#content').width(); /* Get the width of the content container */
var contentWdthRemaining = contentWdth - headlineWdth; /* Content width minus headline width equals the remaining width of the content container */
var posSubtract = contentWdthRemaining / 2; /* Remaining content container width will be divided by 2, that way it can be later subtracted from the offset position
in order for us to place the content container directly bellow the headline */
$('#content').css({'left': pos.left - posSubtract}); /* Place content container right bellow the headline */
$('#content').slideDown('fast'); /* Show content container with a fast slide down animation */
}, function () { /* The headline is not hovered upon anymore */
$('#content').hide(); /* immediately hide the content container */
$('#content').html(''); /* Clear previous html input so it won't be seen in the page inspector tool */
});