标签:head etl padding round doc asc utf-8 time idt
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title></title> <style> * { margin: 0; padding: 0; } div { margin-top: 10px; width: 100px; height: 50px; background-color: purple; position: absolute; } </style> </head> <body> <input type="button" value="移动到400px" id="bt1"/> <input type="button" value="移动到800px" id="bt2"/> <div id="dv"></div> <script src="common.js"></script> <script> my$("bt1").onclick = function () { //获取div当前的left值 var left = my$("dv").offsetLeft; var step = 10; timeId = setInterval(function () { if (left <= 400) { left += step; my$("dv").style.left = left + "px"; console.log(left); } else { clearInterval(timeId); } }, 10) }; my$("bt2").onclick = function () { //获取div当前的left值 var left = my$("dv").offsetLeft; var step = 10; timeId = setInterval(function () { if (left <= 800) { left += step; my$("dv").style.left = left + "px"; console.log(left); } else { clearInterval(timeId); } }, 10) }; </script> </body> </html>
标签:head etl padding round doc asc utf-8 time idt
原文地址:https://www.cnblogs.com/cuilichao/p/9407272.html