[jQuery] .eq(variable) strange behaviour
Hi!
I'm trying to have a menu for which each item loads after the
preceding one is loaded. For this purpose, I wrote the following
function:
function menuLoading(currentMenuItem,menuLength){
console.log(currentMenuItem);
currentMenuItem++;
if(currentMenuItem<=menuLength){
$('.menu li').eq(currentMenuItem).animate({"opacity" : 1},
3000).animate({"opacity" : 0.6}, 2000 ,menuLoading
(currentMenuItem,menuLength));
}
}
Initially, the li items of the menu are set at opacity 0. With the
function I modify the opacity. I'd like every item to start loading
when the previous one is shown. However, all the elements appear at
the same time. If I replace eq(currentMenuItem) by eq(1), only the
first is shown.
How could I make it?
Thanks a lot!
ps: $('.menu li:eq(' + currentMenuItem + ')').animate({"opacity" : 1},
3000).animate({"opacity" : 0.6}, 2000 ,menuLoading
(currentMenuItem,menuLength)); works like the code above bu does not
do what is expected