Javascript examples for jQuery Method and Property:animate
Animate margin right
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $(".btn1").click(function(){ $("#p1").animate({marginRight: "+=200px"}); });// ww w .java 2s . c o m $(".btn2").click(function(){ $("#p1").animate({marginRight: "-=200px"}); }); }); </script> </head> <body> <button class="btn1">Animate +</button> <button class="btn2">Animate -</button> <div>This is a paragraph.</div> <p id="p1" style="border:1px solid blue;">This is an animated paragraph.</p> <div>This is a paragraph.</div> </body> </html>