<div class="htmlarea"> <textarea id="runcode25049"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>JavaScript 개체 번역 이동 효과</title> <style> #div1 {background: red url(http://www.jb51.net/images/logo.gif); position:absolute; left:50px; top:50px; width:200px; height:200px;} </style> <div id="div1"> </div> <input id="btn_start_move" type="button" value="开始运动"> </textarea> <br><input onclick="runEx('runcode25049')" type="button" value="运行代码"><input onclick="doCopy('runcode25049')" type="button" value="复制代码"> <input onclick="doSave(runcode25049)" type="button" value="保存代码"> <a href="http://www.jb51.net/article/23421.htm" title="查看具体详情" target="_blank">[Ctrl A 모두 선택 참고: </a>외부 J를 도입해야 하는 경우 실행하려면 새로 고쳐야 합니다 </div>]<script type="text/javascript"> var g_oTimer=null; function startMove() { if(!g_oTimer) { g_oTimer=setInterval(moveTimerHandler, 30); } } function moveTimerHandler() { var oDiv=document.getElementById('div1'); var iSpeed=5; if(oDiv.offsetLeft>=300) { clearInterval(g_oTimer); g_oTimer=null; } else { oDiv.style.left=oDiv.offsetLeft + iSpeed + 'px'; } } window.onload=function () { var oBtn=document.getElementById('btn_start_move'); oBtn.onclick=startMove; }; </script>