一段指定时间后隐藏层的js代码

法一:
//指定时间隐藏层
function hiddenDiv(layer, sec){
 if(sec < 1) sec = 3;
 sec = (sec<1 ? 3 : sec) * 1000;
 setTimeout(“document.getElementById(‘” + layer + “‘).style.display = ‘none’;”, sec);
}

 

法二:
function hideDiv(id){
 document.getElementById(id).style.display = “none”;
}

function delayedHide(id, time){
 var fn = function(){
  hideDiv.apply(this, [id]); 
 }
 setTimeout(fn, time);
}

delayedHide(“mydiv”, 2000);

第二种方法没有试验过,不知能否成功,大家不仿参考一下

8 thoughts on “一段指定时间后隐藏层的js代码

  1. Pingback: Dentist Anchorage AK

  2. Pingback: rubiks.glove.co.il

  3. Pingback: fun88

  4. Pingback: พนันบอล

  5. Pingback: paragnost

  6. Pingback: cbd oil

  7. Pingback: dang nhap w88

  8. Pingback: estared.net

Leave a Reply