<table>
<tr>
<td id="td1" style="background-color:#00FF00" onclick="test()">adf</td>
</tr>
</table>
<SCRIPT LANGUAGE=javascript>
<!--
function test(){
alert(td1.style.backgroundColor)
}
//-->
</SCRIPT>
<tr>
<td id="td1" style="background-color:#00FF00" onclick="test()">adf</td>
</tr>
</table>
<SCRIPT LANGUAGE=javascript>
<!--
function test(){
alert(td1.style.backgroundColor)
}
//-->
</SCRIPT>
解决方案 »
- 点击小图显示大图,怎样判断大图已经加载完毕?
- attachEvent的困惑
- 如何使用javascript下FileSystemObject对象获取linux服务器上/proc/stat文件内容
- js 改变图片内容?
- js脚本 如何 打开文档doc,excel,text
- js中有没有ascii码和字符串间的转换函数
- 随机显示指定数字的程序,已选中的数字不再出现了,如何做到?
- 急啊!修改注册表的问题!----在线等待
- 用什么方法能遍历出一个对象的所有属性来
- js如何定义一个全局变量供所有的js文件用
- 赐教:我们公司还处于MODEM上网阶段,时间也限制,只要你知道就快给我说——我想右键在IE的工具栏点击被屏蔽如何完成?
- (请教)关于style中的expression问题
<td id="td1" style="background-color:#00FF00" onclick=alert(td1.style.backgroundColor)>adf</td>
</tr></table>
和直接写style应该是一样的
#td1{background-color:#00FF00}
</style>
<table border=1><tr>
<td id="td1" onclick=alert(td1.currentStyle.backgroundColor)>adf</td>
</tr></table>
onMouseOve="this.style.class='ClassOver'"
用style能引用的仅仅是内联样式中所定义的静态样式
<script>document.write("初始的style是:"+a1.style.color+"<br>初始的runtimeStyle是:"+a1.runtimeStyle.color+"<br>初始的currentStyle是:"+a1.currentStyle.color)</script><br>
<input type=button value=runtimeStyle onclick="a1.runtimeStyle.color='blue';show()">
<input type=button value=恢复本来的颜色 onclick="a1.runtimeStyle.color=a1.style.color">
<br>
<script>
function show(){
alert("当前的style是:"+a1.style.color+"\r当前的runtimeStyle是:"+a1.runtimeStyle.color+"\r当前的currentStyle是:"+a1.currentStyle.color+"\r\r看到了吧,style依然没有变化,可是当前显示的颜色是蓝色,currentStyle显示的就是当前的颜色;使用a1.runtimeStyle.color=a1.style.color就可以恢复原来的颜色");
}</script><hr>
<style>
p{color:red}
</style>
在不是行内定义的样式情况下,style可能显示的值是空,这是就可以使用currentStyle
<p onclick='alert("this.style.color = "+this.style.color+"\rthis.currentStyle.color = "+this.currentStyle.color)'>currentStyle的例子!点击这里</p>