setAttribute

来源:互联网 发布:网页视频抓取工具 mac 编辑:程序博客网 时间:2024/04/19 12:33

 

 

 

在 IE6.0 下 setAttribute("Style","display:none") 等Style的属性不备支持。

要用 .style.display="none"代替

FireFox是支持的

例子:

 

<!DOCTYPE   HTML   PUBLIC   "-//W3C//DTD   HTML   4.01   Transitional//EN "> 
<html> 
    
<head> 
    
<meta   http-equiv= "content-type "   content= "text/html;   charset=GBK "> 
  
    
<title> </title> 
    
<script language="javascript"> 
  
function test()
        
var   o=document.getElementById("testbtn"); 
        
//o.setAttribute("Style","display:none");    //1---IE don't  Supported
        o.style.display="none";        //1--IE Supported
        //o.setAttribute("disabled","true");        //IE and FireFox Supported      
  }
 
    
</script> 
    
</head> 
  
<body onload="test();"> 
    
  
<table   border="1"> 
  
<tr> <td> ab </td> <td> cd </td> 
  
</tr> 
  
<tr> <td> ef </td> <td> gh </td> 
  
</tr> 
  
</table> 
    
<input id="testbtn" type="button" onClick="test();" value="test3">
    
    
</body> 
</html> 
原创粉丝点击