Copy it first and see the running effect. The essence used is the setInterval() method: Copy the code The code is as follows: JavaScript<br>html<br>{<br>background- color:silver;<br>}<br>.point1<br>{<br>position:absolute;<br>left:10px;<br>top:40px; <p>}<br>.point2<br>{<br>position:absolute;<br>left:100px;<br>top:40px;<br>}<br>.hr1<br>{<br> position:absolute;<br>top:60px;<br>}<br><br>document.onmousedown = mousedown;<br> document.onmouseup = mouseup;<br>var intervalProcess;<br>var direct = true;<br>function mousedown(){<br>intervalProcess = setInterval("MovePoint()", 1);<br>}<br>function mouseup(){<br>clearInterval(intervalProcess);<br>}<br>function MovePoint(){<br>with (document.getElementById("point1").style){<br>if (isNaN( parseInt(left)))<br>left = "10px";<br>else {<br>document.getElementById("point2").style.left = "200px";<br>if (parseInt(left) < ; 0)<br>direct = true;<br>if (parseInt(left) > parseInt(document.getElementById("point2").style.left))<br>direct = false;<br>if (direct )<br>left = parseInt(left) 1 "px";<br>else<br>left = parseInt(left) - 1 "px";<br>}<br>}<br>}<br>< ;/script><br></head><br><body><br><div class="point1" id="point1"><font color=blue>a</font>< ;/div><br><div class="point2" id="point2"><font color=red>b</font></div><br><hr class="hr1" /><br></body><br></html><br></p> </div>