circular loop (jQuery)
with jQuery
by stofke
HTML
<div id="box"></div>
CSS
#box {
position: absolute;
top: 100px;
left: 100px;
background-color:red;
width: 100px;
height:100px;
}
JavaScript
var loop = function() {
$('#box')
.animate({marginLeft: "+=100px"},1000)
.animate({marginTop: "+=100px"},1000)
.animate({marginLeft: "-=100px"},1000)
.animate({marginTop: "-=100px"},1000,loop);//callback
};
loop();