通过javaScript移动图像 [英] Moving Image By javaScript

查看:69
本文介绍了通过javaScript移动图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何编码移动图像..?

How to code to Move a image..?

推荐答案

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Untitled Page</title>
   <script type="text/javascript">
       var timer;
       function AnimateAero() {
           clearInterval(timer);
           document.getElementById("aero").style.left = "860px";
           timer = setInterval("TakeOff()", 10);
       }
       function TakeOff() {
           document.getElementById("aero").style.pixelLeft -= 2;
           if (document.getElementById("aero").style.pixelLeft < 0) {

               document.getElementById("aero").style.left = "860px";

               TakeOff();

           }

       }

   </script>
</head>
<body>
    <form id="form1" runat="server">
    <div style="position:relative; width:950px; height:350px; border:dashed 1px; background-image:url('clods.jpg'); background-repeat:inherit;" align="right">
        <img id="aero" src="aeroplane.jpg" alt=""; style="position:absolute; left:846px; width: 100px; top: 126px; height: 61px;" onclick="AnimateAero()" />
    </div>
    </form>
</body>
</html>


这篇关于通过javaScript移动图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆