The code that expands and contracts the div
is the following: (found in html part of jsFiddle)
<script>
$('li.dropdown').hover(
function()
{
$(this).find('ul').stop().slideDown(2000);
},
function()
{
$(this).find('ul').stop().slideUp(2000);
})
</script>
Let's analyze this code a bit:
If we hover
over li.dropdown
, then
function(){ $(this).find('ul').stop().slideDown(2000); } //Will execute.
If we hover
out of li.dropdown
, then
function(){ $(this).find('ul').stop().slideUp(2000); } //Will execute
Hence, the code does not cover 'nested' animations.
There are many ways to solve this problem but I think the most beautiful one would be:
<script>
$('li.dropdown').hover(function()
{
$(this).find('ul').stop().slideToggle(2000);
});
</script>
You can find a working example in this jsFiddle.
I hope that answers your question.