JavaScript 运动之匀速运动

发布时间:2024-12-09 03:17

运用快门捕捉运动中的速度和力量,展现运动之美。 #生活乐趣# #运动健身乐趣# #运动摄影#

最新推荐文章于 2022-02-26 21:37:14 发布

----Neal---- 于 2015-05-22 09:46:25 发布

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

HTML文件代码

<!DOCTYPE html>
<html>
  <head>
    <title>easeSport.html</title>
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <style type="text/css">
    #div1{width: 150px;height: 150px;background:#CEE;position:absolute;top:50px;left:50px;}
    </style>
    <script type="text/javascript" src="../js/easeSport.js"></script>
  </head>
  <body>
    <input type="button" value="start sport" id="btn">
    <input type="button" value="stop sport" id="btn1">
     X:<input type="text" id="txtx" style="20px;">
     Y:<input type="text" id="txty" style="20px;">
    <div id="div1"></div>
  </body>
</html>

js文件代码

window.onload = function(){
    var btn = document.getElementById('btn');
    var btn1 = document.getElementById('btn1');
    var div = document.getElementById('div1');
    var txtx = document.getElementById('txtx');
    var txty = document.getElementById('txty');
    var timer = null;
    var speed = 1;
    btn.onclick = function(){
    clearInterval(timer);
timer = setInterval(function(){
if(div.offsetLeft <= 225){
div.style.top  = div.offsetTop+speed+'px';
}else if(div.offsetLeft <= 400) {
div.style.top  = div.offsetTop-speed+'px';
}
txtx.value = div.offsetLeft;
txty.value = div.offsetTop;
if(div.offsetLeft >= 400){
clearInterval(timer);
}else{
div.style.left = div.offsetLeft+speed+'px';
}
},30); 
btn1.onclick = function(){
clearInterval(timer);
}
    }
    }

网址:JavaScript 运动之匀速运动 https://www.yuejiaxmz.com/news/view/420151

相关内容

一辆平板车静止在水平地面上.质量M=2500kg.车上放一质量m=500kg的重物.重物前侧面到车前的距离为L=3m.如图所示.开始车以a=2m/s2的加速度匀加速启动.6s后改为匀速运动.有经过2s司机发现前方有障碍.立即制动刹车做匀减速运动直到静止.最终重物恰好滑动到车前壁处静止.已知平板车在加速和匀速运动过程中所受阻力� 题目和参考答案——青夏教育精英家教网——
自动化脚本神器:AutoJS —— 移动端的JavaScript自动化工具
自动化技术:用JavaScript打造轻松生活
#运动[超话]# ...
运动之后吃什么
在家运动的方法是什么?家庭运动所需的九种运动
世界最受欢迎的水上运动之划船运动
对速度公式v=$\frac{s}{t}$的理解.正确的是( )A.运动的路程越长.速度越大B.运动的时间越短.速度越大C.匀速直线运动的速度与路程s和时间t无关D.一定时间内.平均速度越大的通过的路程越小 题目和参考答案——青夏教育精英家教网——
某质点以a=2m/s2的恒定加速度做匀加速直线运动,下列说法正确的是( )
如图所示,传送带与水平方向间的夹角为37°,绷紧的传送带AB始终保持v=1 m/s的恒定速率运动。质量m=4 kg的小物块无初速度地放在A处,传送带对物块的摩擦力使物块开始做匀加速运动,随后物块又以与传送带相同的速率做匀速直线运动。物体与

随便看看