6.2.17 匀速运动案例

匿名 (未验证) 提交于 2019-12-03 00:43:02

<!DOCTYPE html> <html> 	<head> 		<meta charset="UTF-8"> 		<title></title> 		<style type="text/css"> 			*{padding: 0;margin: 0;} 			.box{ 				width: 200px; 				height: 200px; 				background-color: #FF0000; 				position: absolute; 				top: 50px; 				left: 0px; 			} 		</style> 	</head> 	<body> 		<div id="wrap"> 			 			<button id="btn">运动</button> 			<div class="box" id="box1"> 				 			</div> 			 		</div> 	</body> 	<script type="text/javascript"> 		var btn = document.getElementById(‘btn‘); 		 		var box1 = document.getElementById(‘box1‘) 		 		var count  = 0; 		var time = null; 		btn.onclick = function(){ 			 			time = setInterval(function(){ 				count+=10; 				if(count>1000){ 					clearInterval(time) 					box1.style.display = ‘none‘ 				} 				 				box1.style.left = count + ‘px‘				 				 			},10) 			 		} 	</script> 	 </html> 

  

原文:https://www.cnblogs.com/beallaliu/p/9348072.html

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!