In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
Because the numeric decimal point in JS is automatically removed, for the motion position, you need to use Math.ceil () to round up or
Math.floor () rounding down to solve the problem
Here is my simple code for buffering exercise
Untitled document # div1 {width:200px;height:200px;background:red;left:0px;top:50px;position:absolute;} # div2 {width:1px;height:250px;background:black;left:400px;top:20px;position:absolute;} _ window.onload=function () {var oDiv=document.getElementById ('div1'); var oBtn=document.getElementById (' btn1'); oBtn.onclick=function () {startMove }}; var timer=null;function startMove (target) {var oDiv=document.getElementById ('div1'); var speed=0 ClearInterval (timer) timer=setInterval (function () {/ / speed will be rounded directly and the remainder will be rounded off, so the position is not accurate, so we need to solve speed=Math.ceil ((target-oDiv.offsetLeft) / 10) by rounding up Math.ceil (); oDiv.style.left=oDiv.offsetLeft+speed+'px' Document.title=oDiv.offsetLeft+','+speed;}, 30);}
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.