window.onload=function(){
nav=document.getElementById('nav');
share=document.getElementById('share');
flag=0;
share.onmouseover=function(){
share.style.background='rgba(120,0,0,0.8)';
}
share.onmouseout=stopFun;
share.onclick=function(){
if (flag==0) {
setInterval(play,30);
clearInterval(play);
flag=1;
}else{
setInterval(stop,30);
clearInterval(stop);
flag=0;
}
}
function play(){
nav.style.left=nav.offsetLeft+10+'px';
if (nav.offsetLeft>=0) {
nav.style.left=0;
}
}
function stop(){
nav.style.left=nav.offsetLeft-10+'px';
if (nav.offsetLeft<=-132) {
nav.style.left=-132+'px';
}
}
}
function stopFun(){
share.style.background='gray';
}
这是用来实现点击按钮弹出一个侧框,再次点击复原,但是却复原不了
Cassie_yu
相关分类