I am trying to debug the following script to ensure the best, desired UX. This script is not working quite as desired, as seen on this fiddle.
$("ul.menu li").mouseover(function() {
$(this).find("ul.sub-menu").animate({"opacity": "show"}, 800, "swing");
$(this).hover(function() {}, function(){
$(this).find("ul.sub-menu").animate({"opacity": "hide"}, "slow");
});
});
As you can see the animations don’t trigger initially. Also if the user accidentally hovers over multiple links then undesired animations get stuck playing for many seconds onward. I want to edit this responsiveness. What are currently some of the top ways to deal with this in professional UI design when working with jQuery and how can I implement these solutions into my script?
You are nesting
mouseover()and.hover()which was the main issue. You just simply want to show something when you hover over it, and then reverse the animation when you hover out.Try this: http://jsfiddle.net/pF8wZ/4/
I also cleaned up your CSS from the fiddle. You just need this to make the hovering behavior work:
And the HTML: