Reputation: 227
I currently have a bit of jQuery that opens up a div below it from my menu. It works great, however It's not a drop-down but an extra menu.
I want to keep the div 'quickCourse' open if the mouse is inside that div.
So I only want the div to close if the mouse is not over the li:nth-of-type(6) or the quickCourse div. Any help or direction would be greatly appreciated.
I have a feeling it's to do with mouseOver but a little unsure? - A JSfiddle of what I have so far is available here:
http://jsfiddle.net/owenoneill/REyRg/11/
<script type="text/javascript">
$(document).ready(function () {
$(".header ul.menu > li:nth-of-type(6) ").hover(
function () {
$("div.quickCourse").fadeIn();
},
function () {
$("div.quickCourse").fadeOut();
}
);
});
</script>
Upvotes: 1
Views: 3407
Reputation: 28554
$(document).ready(function() {
$(".header ul.menu > li:nth-of-type(6)").mouseover(function() {
$("div.quickCourse").fadeIn();
});
$(".header ul.menu > li:nth-of-type(6), div.quickCourse").mouseleave(function() {
$("div.quickCourse").fadeOut();
});
$("div.quickCourse").mouseover(function() {
$(this).stop(true, true).show();
});
});
.header ul.menu {
float: left;
list-style-type: none;
}
.header ul.menu li {
float: left;
padding: 10px;
}
.quickCourse {
position: absolute;
margin: 80px 0px 0px 0px;
width: 300px;
height: 30px;
background: #000;
display: none;
color: #FFF;
padding: 50px;
text-align: center;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="header">
<ul class="menu">
<li>TEST 1</li>
<li>TEST 2</li>
<li>TEST 3</li>
<li>TEST 4</li>
<li>TEST 5</li>
<li>TEST 6</li>
</ul>
</div>
<div class="quickCourse">HULLO!</div>
Upvotes: 3