I have created a collapsible menu with stucture like:
- Parent
- Parent 2
- Parent 3
- Sub category
I have the following javascript
var config = {
over: function() { $(this).children('ul').slideDown('slow'); },
timeout: 5,
out: function() { }
}
$("ul.root-tags li").hoverIntent(config);
$('ul.root-tags').mouseout(function() {
$(this).children('li ul').each(function () {
$(this).slideUp('slow');
});
});
Basically I want to open sub categories on hover of the parent item but only collapse opened subcategories on mouseout of the entire list, not just the parent item. My current code does not do this. What changes do I need to make?
jsfiddle is here http://jsfiddle.net/zkhVC/4/
This should address what you are asking for:
Fiddle
Here
Explanation
hoverevent, because it will get fired over and over again you are over the element. You want to usemouseenterinstead.mouseleaveinstead ofmouseout:childrenfunction here.stopfunction before calling an animation to prevent animations buffering.