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

  作者:bea

在IE7中, 使用jQuery 显示:$("#a").attr("style",""); 隐藏:$("#a").attr("style","display:none"); 但是显示这个方法在IE8中不行 IE8 显示:$("#a").removeAttr("style"); 隐藏:$("#a").attr("style","display:none"); IE6,最怪异,使用display:none不能隐藏select标签 下面这两个,经测试,在三个版本中都能正常使用 隐藏:
在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="";


有用  |  无用

猜你喜欢