I’m applying a simple animation to a div when hovering an id. The div is not a child of the id. So when my cursor leaves the id the div hides itself.
This is correct, but I require the div to stay visible unless my mouse leaves it.
You may have to test to see my issue. Link is below.
Heres my jQuery:
$(function(){
$('.has-children').hover(function(){
var the_handle = $(this).attr('id');
var the_sub_nav = '#' + the_handle + '-sub-nav';
$(the_sub_nav).stop().animate({height:'200px'},1000);
},function(){
var the_handle = $(this).attr('id');
var the_sub_nav = '#' + the_handle + '-sub-nav';
$(the_sub_nav).stop().animate({height:'0px'},1000);
});
});
Here is a link to the issue:
(I should mention I’m resticted to that HTML code. I’m using an e-commerce platform and thats the only way I can create sub-categories)
Here a simple JSFiddle for you http://jsfiddle.net/toroncino/uPDXX/1/
Edit: Here a short version: http://jsfiddle.net/toroncino/uPDXX/3/
EDIT 2:
Take a look now, is based on your current html… obviously I will never use a js like that. =) but maybe it will help you…
http://jsfiddle.net/toroncino/uPDXX/5/