日期:2014-05-16  浏览次数:20359 次

急!下面这段JS如何实现延时响应
function   setFocus3(i)
{
  selectLayer3(i);
}
function   selectLayer3(i)
{
  switch(i)
  {
  case   1:
  document.getElementById( "pic10 ").style.display= "block ";
  document.getElementById( "pic11 ").style.display= "none ";
  break;
  case   2:
  document.getElementById( "pic10 ").style.display= "none ";
  document.getElementById( "pic11 ").style.display= "block ";
  break;
  }
}

------解决方案--------------------
LZ试下下面的代码

JScript code

function   setFocus3(i) 
{ 
  setTimeout("selectLayer3(" + i + ");", 1000); 
} 
function   selectLayer3(i) 
{ 
  switch(i) 
  { 
  case   1: 
  document.getElementById( "pic10 ").style.display= "block "; 
  document.getElementById( "pic11 ").style.display= "none "; 
  break; 
  case   2: 
  document.getElementById( "pic10 ").style.display= "none "; 
  document.getElementById( "pic11 ").style.display= "block "; 
  break; 
  } 
}