먼저 복사하여 실행 효과를 확인하세요. 사용된 핵심은 setInterval() 메서드입니다. 코드 복사 코드는 다음과 같습니다: JavaScript<br>html<br>{<br>배경 - 색상:실버;<br>}<br>.point1<br>{<br>위치:절대;<br>왼쪽:10px;<br>상단:40px; <p>}<br>.point2<br>{<br>위치:절대;<br>왼쪽:100px;<br>상단: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(왼쪽)))<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 (직접 )<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>