JS多物体 任意值 链式 缓冲运动
更新时间:2012年08月10日 17:09:57 作者:
JS多物体 任意值 链式 缓冲运动,需要的朋友可以参考下
复制代码 代码如下:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" charset="utf-8" />
<meta http-equiv="content-type" content="text/html" />
<title>demo</title>
</head>
<style type="text/css">
ul,li,img{margin:0;padding:0;border:0;}
#list{height:250px;list-style-type:none;overflow:hidden;}
</style>
<body>
<div id="odiv" style="position:absolute;width:200px;height:100px;background:red;left:0;border:1px solid #333;"></div>
<script type="text/javascript">
var odiv=document.getElementById('odiv');
odiv.onmouseover=function(){
move(this,'width',500,function(){
move(odiv,'left',300,function(){
move(odiv,'height',500,function(){
move(odiv,'borderWidth',10)
})
})});}
function move(obj,arr,target,fn){
var dt=null,speed=0,ol=0;
clearInterval(dt);
dt=setInterval(function(){
ol=parseInt(obj.style[arr]);
if(ol==target){
clearInterval(dt);
if(fn) fn();
}else{
speed=(target-ol)/8;
speed>0?speed=Math.ceil(speed):speed=Math.floor(speed);
obj.style[arr]=ol+speed+"px";
}
},30);
}
</script>
</body>
</html>
相关文章
关于js复制内容到浏览器剪贴板报错:Cannot read properties of&n
这篇文章主要给大家介绍了关于js复制内容到浏览器剪贴板报错:Cannot read properties of undefined (reading ‘writeText‘)的解决方案,文中给出了详细的原因分析和解决方案,需要的朋友可以参考下2024-01-01
JavaScript中报错Cannot set properties of undefined (settin
这篇文章主要介绍了JavaScript中报错Cannot set properties of undefined (setting '1')的解决方案,文中通过代码介绍的非常详细,对大家学习或使用js具有一定的参考借鉴价值,需要的朋友可以参考下2025-03-03
记录微信小程序 height: calc(xx - xx);无效问题
这篇文章主要介绍了微信小程序 - height: calc(xx - xx);无效 问题,文中给大家扩展介绍下jquery点击添加样式,再次点击移除样式的实例代码,需要的朋友可以参考下2019-12-12
检查输入的是否是数字使用keyCode配合onkeypress事件
检查输入的是否是数字在本文使用keyCode配合onkeypress事件来实现,具体示例如下2014-01-01


最新评论