關于JS展開與收縮課程最后編程題的更改
<script type="text/javascript">
function getDOM(id) {
return document.getElementById(id);
}
var timer=null;
newTimer=null,
pn=getDOM("pn");
window.onload=function () {
startMove(600);
newTimer=setTimeout(function () {
startMove(0);
},5000)
}
//个人方法--------------
function startMove(iTarget) {
if (timer){
clearInterval(timer);
}
timer=setInterval(function () {
var speed=0;
pn.offsetWidth<iTarget?speed=10:speed=-10;
if (pn.offsetWidth==iTarget){
clearInterval(timer);
if (pn.style.width==0+'px'){
pn.style.display='none';
}
}else {
pn.style.display='block';
pn.style.width=pn.offsetWidth+speed+'px';
}
},30)
}
點擊查看更多內容
2人點贊
評論
評論
共同學習,寫下你的評論
評論加載中...
作者其他優質文章
正在加載中
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦