<html> <head><title>moving objects using animate</title></head> <body> <div id="box"> </div><br /> <br /> <button id="left"><<</button> <button id="right">>></button> </body> </html>
$(document).ready(function() { $("#left").click(function() { $("#box").animate({ "marginLeft":"-=40px" },"slow"); }); $("#right").click(function() { $("#box").animate({ "marginLeft":"+=40px" },"slow"); }); });
#box { background-color:Orange; height:100px; width:100px; margin-left:40px; margin-top:40px; }