对于@qq_沃德天维森陌拉莫帅yb_0 同学说的为了方便而不在参数里设置type,那也只是对于这个点击事件来说方便了,如果想要设置其它事件,那还要一个个进函数里修改。这里加上是为了函数的抽象化,增加函数的复用性,以后想要设置其它事件了,直接在参数里设置就好了,这样更方便调用。
2017-04-24
window.onload=function(){
play.onclick=playFun;
stop.onclick=stopFun;
document.onkeyup=keyFun;
}
function keyFun(event){
var event=event||window.event;
if(event.keyCode==13){
timer?stopFun():playFun();
}
};
play.onclick=playFun;
stop.onclick=stopFun;
document.onkeyup=keyFun;
}
function keyFun(event){
var event=event||window.event;
if(event.keyCode==13){
timer?stopFun():playFun();
}
};
2017-04-24
function playFun(){
if(timer) return;
timer=setInterval(function(){
var r=Math.floor(Math.random() * data.length);
title.innerHTML=data[r];
},50);
play.style.background='#999';
}
function stopFun(){
if(!timer) return;
clearInterval(timer);timer=null;
play.style.background='#036';
}
if(timer) return;
timer=setInterval(function(){
var r=Math.floor(Math.random() * data.length);
title.innerHTML=data[r];
},50);
play.style.background='#999';
}
function stopFun(){
if(!timer) return;
clearInterval(timer);timer=null;
play.style.background='#036';
}
2017-04-24
document.onclick=function(event){
var event=event||window.event;
var element=event.target||event.srcElement;
if(element.className.indexOf('login-state')==-1){
loginStatePanel.style.display='none';
}
};
var event=event||window.event;
var element=event.target||event.srcElement;
if(element.className.indexOf('login-state')==-1){
loginStatePanel.style.display='none';
}
};
2017-04-21
loginState.onclick=function(){
var display= loginStatePanel.style.display;
loginStatePanel.style.display= display=='block'?'none':'block';
};
var display= loginStatePanel.style.display;
loginStatePanel.style.display= display=='block'?'none':'block';
};
2017-04-21
function liClick(event){
//var element=event.target||event.srcElement;
var clsName=this.children[0].className.split(' ')[1];
var txt=this.children[1].innerHTML;
loginStateShow.className='login-state-show '+clsName;
stateTxt.innerHTML=txt;
}
//var element=event.target||event.srcElement;
var clsName=this.children[0].className.split(' ')[1];
var txt=this.children[1].innerHTML;
loginStateShow.className='login-state-show '+clsName;
stateTxt.innerHTML=txt;
}
2017-04-21
.statePanel .statePanel_li:hover{
background:#567;
}
background:#567;
}
2017-04-21