为了账号安全,请及时绑定邮箱和手机立即绑定

<script type="text/javascript">

window.onload = function(first_argument) {

var obj = document.getElementsByTagName("li");

var width = obj[0].style.width;

for(var i=0; i<obj.length; i++){

obj[i].timer = null;

obj[i].onmouseover = function(){

startMove(this, 500, true);

}

obj[i].onmouseout = function(){

startMove(this, 100, false);

}

}

}

//var timer = null;

function startMove(obj, targes, status){

clearInterval(obj.timer);

var speed = (targes - obj.offsetWidth)/10 ;

speed = speed > 0 ? Math.ceil(speed) : Math.floor(speed);

console.log(speed);

obj.timer = setInterval(function(){

if(status){

if(obj.offsetWidth > targes){

clearInterval(obj.timer);

}else{

obj.style.width = obj.offsetWidth + speed + "px";

}

}else{

if(obj.offsetWidth < 100){

clearInterval(obj.timer);

}else{

obj.style.width = obj.offsetWidth + speed + "px";

}

}

}, 30);

}

</script>


正在回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信