Sublime Text
<!DOCTYPE html> <html> <head> <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.12.0.min.js"></script> <style type="text/css"> .father{ border:1px solid #555; margin-top:20px; height:230px; width:430px; position:relative; } .child{ background-color:blue; position:absolute; width:30px; height:30px; } </style> </head> <body> <button id="start">Start</button> <button id="stop">Stop</button> <div class="father"> <div class="child"></div> </div> <script> $(document).ready(function(){ $("#start").click(function(){ $(".child").animate({left:"400px"},3000); $(".child").animate({top:"200px"},3000); $(".child").animate({left:"0px"},3000); $(".child").animate({top:"0px"},3000); }); $("#stop").click(function(){ $(".child").stop(); }); }); </script> </body> </html>
<!DOCTYPE html> <html> <head> <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.12.0.min.js"></script> <style type="text/css"> .father{ border:1px solid #555; margin-top:20px; height:230px; width:430px; position:relative; } .child{ background-color:blue; position:absolute; width:30px; height:30px; } </style> </head> <body> <button id="start">Start</button> <button id="stop">Stop</button> <div class="father"> <div class="child"></div> </div> <script> $(document).ready(function(){ $("#start").click(function(){ $(".child").animate({left:"400px"},3000); $(".child").animate({top:"200px"},3000); $(".child").animate({left:"0px"},3000); $(".child").animate({top:"0px"},3000); }); $("#stop").click(function(){ $(".child").stop(); }); }); </script> </body> </html>