var contentbody = document.getElementById("main"),
timer = null,
i = 0;
if(contentbody.style.marginLeft=="")
{
timer = setInterval(function() {
i++;
contentbody.style.marginLeft=i + 'px';
}, 50);
if(parseInt(contentbody.style.marginLeft) > 50) {
clearInterval(timer);
}
}else{
contentbody.style.marginLeft="";
}
// 未自己运行,不保证代码完全正确,但是思路是这样的
demo:http://www.wusichao.com/demo/admin_template/

修改了JS代码,借着「看不懂未来」大神写的运动JS代码段来实现的,但是目前还有些问题,没办法停止,请各位大神帮忙看看。
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
题意有些不明,说说你想实现什么吧?用这个for来实现?
Edit by Kumfo,start
我也想知道题主想问一个什么问题,没搞清楚要实现什么,搞不清楚要实现什么就不知道怎么搞啊!!!
Edit by KUmfo,end
你需要setTimeout: Demo