I have successfully created a slidedown function that utilizes data in links to execute actions on specific sections. The script works well, however, there is an issue when trying to access the content within the section. Whenever I hover over the link, the section appears but it disappears when I try to interact with the content inside. How can I make the section stay visible as long as my mouse is hovering over the content without needing to change the HTML structure? Additionally, how can I keep the link underlined while the section is being hovered over?
HTML
<ul class="main-navbar-right">
<li><a href="#" data-navigation="home">Home</a></li>
<li><a href="#" data-navigation="explore">Explore</a></li>
<li><a href="#" data-navigation="news">News</a></li>
</ul>
<div class="navigation-content">
<section id="-navbar-home" data-section="home">
<p>Home, some content with images, videos, and more and <a href="#">Link</a></p>
</section>
<section id="-navbar-explore" data-section="explore">
<p>Explore home <a href="#">Link</a></p>
</section>
<section id="-navbar-news" data-section="news">
<p>News about home <a href="#">Link</a></p>
</section>
</div>
CSS
#-navbar-home,
#-navbar-explore,
#-navbar-news {
display: none;
}
a {
text-decoration: none;
}
ul {
width: 100%;
display: block;
}
li {
float: left;
margin: 0 15px 0 0;
}
.active, a:hover {
text-decoration: underline;
}
JavaScript
var element;
$('li > a').hover(function() {
var navigation = $(this).data("navigation");
var section = $("section[data-section="+navigation+"]");
element = $(section).slideDown();
}, function() {
element.hide()
});
Check out the fiddle here: http://jsfiddle.net/66qz2by8/6/