<script>
function swim() {
$("#ship").animate({left: "-=-540px"}, 3000, function() {
$("#ship").css("-moz-transform", "scaleX(-1)");
$("#ship").css("-o-transform", "scaleX(-1)");
$("#ship").css("-webkit-transform", "scaleX(-1)");
$("#ship").css("transform", "scaleX(-1)");
$("#ship").css("filter", "FlipH");
$("#ship").css("-ms-filter", "FlipH");
$("#ship").animate({left: "-=540px"}, 3000);
swim();
})
}
swim();
</script>
When I use only document.ready works fine, but stops after an attempt to turn it to a loop. There must be a syntax bug somewhere but I can't figure out where.
EDIT: nvm. It was the case of putting the script to <head> instead of <body>.
function(){}you can usethisinsead of repeating query.