时间:2021-07-01 10:21:17 帮助过:36人阅读
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>自定义动画</title> <script type="text/javascript" src="jquery.1.12.4.js"></script> <style> * { margin: 0; } </style> <script type="text/javascript"> var moveToLeft = function () { $("#topImg").animate( { "left": "0" } , "slow", moveToRight); } ; var moveToRight = function () { $("#topImg").animate( { "left": "100px" } , "slow", moveToLeft); } ; $(function () { $("button").click(moveToRight); } ); </script></head><body><button>点击我右移100px</button><br/><br/><br/><br/><img id="topImg" style="position: absolute; left: 0" src="图片1_30.jpg"/></body></html>
以上就是javascript实现图片左右移动的方法的详细内容,更多请关注Gxl网其它相关文章!