<html> <head> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $(".btn1").click(function(){ $("p").animate({top:"100px"}); }); $(".btn2").click(function(){ $("p").animate({top:"0px"}); }); }); </script> </head> <body> <button class="btn1">Animate</button> <button class="btn2">Reset</button> <div style="position:relative"> <p style="background-color:yellow;width:100px;position:absolute">This is a paragraph.</p> </div> </body> </html>
结果:
编辑上面的代码,点击查看结果。
yige.org
- 试一个