W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<html> <head> <script type="text/javascript" src="/jquery/jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $(".btn1").click(function(){ $("body").animate({ backgroundPositionX: "+=100px", backgroundPositionY: "+=200px" },0); }); $(".btn2").click(function(){ $("body").animate({ backgroundPositionX: "0px", backgroundPositionY: "0px" },0); }); }); </script> </head> <body style="background-image:url(/i/eg_background.jpg);background-repeat:no-repeat;background-attachment:fixed;"> <p>This is a paragraph.</p> <button class="btn1">Animate</button> <button class="btn2">Reset</button> </body> </html>