站长资源网络编程

JS控制显示隐藏兼容问题(IE6、IE7、IE8)

整理:jimmy2026/8/6浏览2
简介在IE7中, 使用jQuery 显示:$("#a").attr("style",""); 隐藏:$("#a").attr("style","display:none"); 但是显示这个方法在IE8中不行 IE8 显示:$("#a").removeAttr("style"); 隐藏:$("#a").a
在IE7中,

使用jQuery

显示:$("#a").attr("style","");

隐藏:$("#a").attr("style","display:none");

但是显示这个方法在IE8中不行

IE8

显示:$("#a").removeAttr("style");

隐藏:$("#a").attr("style","display:none");

IE6,最怪异,使用display:none不能隐藏select标签

下面这两个,经测试,在三个版本中都能正常使用

隐藏:document.getElementById("a").style.display="none";

显示:document.getElementById("a").style.display="";