js渐隐渐入渐出效果 fadeOut fadeIn

    //fadeOut
//function start
function fadeOut(ele,speed){
var ele=document.getElementById(ele);
var opacitynum=ele.style.opacity||1;
var speed=(speed/100)||10;
function opacityOff(){
if(opacitynum>0){
ele.style.opacity=opacitynum=(opacitynum-0.01).toFixed(2);
}else{
clearInterval(opacityt);
}
}
var opacityt=setInterval(opacityOff,speed);
}
//function end //fadeIn
//function start
function fadeIn(ele,speed){
var ele=document.getElementById(ele);
var opacitynum=ele.style.opacity||0;
var speed=(speed/100)||10;
function opacityAdd(){
if(opacitynum<1){
ele.style.opacity=opacitynum=(parseFloat(opacitynum)+0.01).toFixed(2);
}else{
clearInterval(opacityt);
}
}
var opacityt=setInterval(opacityAdd,speed);
}
//function end
上一篇:CSS垂直居中查询宝典


下一篇:解决Jquery mobile点击较长文本body的时候Header和footer会渐入渐出的问题