Reputation: 721
Before reading the description please take a look at the drop down menu which I created in JSfiddle
http://jsfiddle.net/akhilpaul/bKxXZ/
I have a JQuery drop down menu which I taken from a tutorial :) and it works great like animate the dropdown function smoothly. The problem is the animation(drop down) when I mouseover the down arrow(now red color) on the right side of the menu but this is not I'm looking actually I need to animate the drop down when I mouseover the menu(Our Services and Locations). And I made slight updates on the JQuery but that dosen't work.. What I extra added to the Jquery is
added a class(.drop) to the particular li that having drop downs and commented the span function like this
//$("ul.subnav").parent().append("<span></span>");
$("ul.topnav li.drop").mouseover(function() {
<li class="drop">
<a href="#">Our Services</a>
<ul class="subnav">
<li><a href="#">Contract</a></li>
<li><a href="#">Sketch</a></li>
<li><a href="#">Implementation</a></li>
</ul>
</li>
Although I try to keep the hover effect of the drop down menu as visible when we move the cursor to drop down menu..
but both functions aren't working!
Looking forward to your replies on this question
Thanks
Paul
Upvotes: 0
Views: 880
Reputation: 91497
You're code can be condensed to just this:
$(function() {
$("ul.topnav li:has(.subnav)").hover(function() {
$("ul.subnav", this).slideDown('fast').show();
}, function() {
$("ul.subnav", this).slideUp('slow');
});
});
Here's what changed:
.mouseover()
selector from selecting the span to selecting any li that has a subnav.$(this).parent()
to just $(this)
since our selector now points at what was the parent..hover()
code..mouseover()
to .hover()
and combine it with the existing .hover()
, since they both apply to the same element.Upvotes: 1
Reputation: 6623
Just change one line:
$("ul.topnav li span").mouseover(function() { ...
Should be:
$("ul.topnav li a").mouseover(function() {
See: http://jsfiddle.net/h5S3c/1/
I just updated it to fix the red/green bars to the right.
Upvotes: 1
Reputation: 10258
Check out this updated fiddle: http://jsfiddle.net/ecy7Q/
I basically changed the
$("ul.topnav li span").mouseover
into
$("ul.topnav li").mouseover
and remove the .parent() from the code that followed.
Upvotes: 0