js跑步演算法

來源:互聯網
上載者:User

標籤:style   blog   http   color   io   os   ar   java   sp   

 1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>JavaScript</title> 5 <style> 6 html 7 { 8 background-color:silver; 9 }10 .point111 {12 position:absolute;13 left:10px;14 top:40px;15 16 }17 .point218 {19 position:absolute;20 left:100px;21 top:40px;22 }23 .hr124 {25 position:absolute;26 top:60px;27 }28 </style>29 <script type="text/JavaScript">30 document.onmousedown = mousedown;31 document.onmouseup = mouseup;32 var intervalProcess;33 var direct = true;34 function mousedown(){35 intervalProcess = setInterval("MovePoint()", 1);36 }37 function mouseup(){38 clearInterval(intervalProcess);39 }40 function MovePoint(){41 with (document.getElementById("point1").style){42 if (isNaN(parseInt(left)))43 left = "10px";44 else {45 document.getElementById("point2").style.left = "200px";46 if (parseInt(left) < 0)47 direct = true;48 if (parseInt(left) > parseInt(document.getElementById("point2").style.left))49 direct = false;50 if (direct)51 left = parseInt(left) + 1 + "px";52 else53 left = parseInt(left) - 1 + "px";54 }55 }56 }57 </script>58 </head>59 <body>60 <div class="point1" id="point1"><font color=blue>a</font></div>61 <div class="point2" id="point2"><font color=red>b</font></div>62 <hr class="hr1" />63 </body>64 </html

js跑步演算法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.