What is the problem with my script? When I execute it, the alert (line 2) gives me "100,200,300undefinedundefined", so is seems like 100,200,300 is interpreted as h1 when I would like it to be h1, h2 and h3 (with the commas).
function myanimation(h1,h2,h3) {
alert(h1 + h2 + h3);
$("#h1").animate({"left": h1});
$("#h2").animate({"left": h2});
}
var moves = new Array()
moves[1] = [100,200,300];
moves[2] = [300,200,100];
moves[3] = [-500,-300,0];
var i = 1;
function animatenow(){
myanimation(moves[i]);
i++;
}
$('#launch').click(function() {
setInterval(animatenow, 5000);
});
You are passing an array into myanimation, which corresponds to your h1 parameter. You aren't passing h2 or h3, so those are undefined.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With