I am trying the following, but cant get the function to run itself again (I am trying to create some kind of looping animation)
$(document).ready(function() {
//function loopingFunction(){
function loop() {
$('#item').animate({top:'+=100'}, 500, function() {
$('#item').animate({top:'-=100'},500, function(){
loop;
});
});
}
});
Either:
Live Example: http://jsfiddle.net/vyef6/
or
Live example: http://jsfiddle.net/w92b2/
Explaination: In the first one, you are literally executing the
loopfunction. Therefore needs the parenthesis. Ine the second you’re passing a reference,or callback, to theloopfunction in toanimate– therefore it doesnt need the parenthesis.