i'm trying div move 1 end of screen other on loop. javascript attempts move div left doesn't work.
var func = function() { $("#bob").animate({"left": "-40px"}, 1000, function() { $(this).animate({"left": "40px"}, 1000) }) settimeout(func, 2000); }
here jsfiddle:
name functions, , use 1 completion callback in other:
function goleft() { $('#bob').animate({'left': '-40px'}, 1000, goright); } function goright() { $('#bob').animate({'left': '40px'}, 1000, goleft); } goleft();
so, when it's done going left, should go right. when it's done going right, should go left.
disclaimer: untested
p.s. you're missing jquery in fiddle.
Comments
Post a Comment