我先在外部链接CSS文件里给tr定义了display:table-row,接着给table的两行分别定义了名为"a","b"的id,但我用document.getElementById(id).style.display却得不到这两行的显示样式,在IE7和FF3.5得到都是空,我试着把样式直接写到HTML标签内,在FF里能得到display,而IE里仍然得不到值,应该怎么改代码才能让两个浏览器都得到值呢?
解决方案 »
- 求用cookie来控制点弹代码每24小时才弹出一次
- 在开发Web报表时如何通过程序连接数据源
- 这段函数定义的循环怎么没见过,请教?
- 【原创:可能是09谢幕之作,开源发布】神魔对决3-梦中的大陆,横板英雄无敌??
- button模拟file,为什么提交的时候file的value值被清空了 急!!!!!
- windows2003企业版下如何安装脚本调试器?
- 想实现一个类似于CSDN -> FAQ列表页的渐变效果
- table.rows;可以获取表格的行数,table.columns却不能获取列数,列要用什么属性?
- 如何模拟在屏幕的100*100处点击的动作
- 窗体对象的问题?高手请进!
- js替换问题
- js图片切换在ie7中不显示,在ie6中正常显示
document.getElementById(id).currentStyle.display
FF:
document.defaultView.getComputedStyle(obj,null)[property]
<script type="text/javascript">
<!--
var CurrentStyle = function(e){
return e.currentStyle || document.defaultView.getComputedStyle(e, null);
}
alert(CurrentStyle(document.getElementById(id))['display']);
//-->
</script>
<tr id=a style="display:table-row;"><td></td></tr>
<tr id=b style="display:table-row;"><td></td></tr>
</table><script language="javascript">
alert(document.getElementById("a").style.display);
</script>
详见:http://www.w3schools.com/css/pr_class_display.asp
<!--
var CurrentStyle = function(e){
return e.currentStyle || document.defaultView.getComputedStyle(e, null);
}
alert(CurrentStyle(document.getElementById(id))['display']);
//-->
</script>