obj.style.backgroundColor为什么取不到值?

| 暂无评论 | 暂无引用通告
obj.style.backgroundColor只能赋值,不能取值,取值要用getComputedStyle或者currentStyle。看下例函数:
function getRealStyle(id, styleName){
var element = document.getElementById(id);
var realStyle = null;
if(element.currentStyle){
realStyle = element.currentStyle[styleName];
}else if(window.getComputedStyle){
realStyle = window.getComputedStyle(element, null)[styleName];
}
return realStyle;
}

暂无引用通告

发送引用通告网址: http://wangblog.org/cgi-bin/mt/tb.cgi/75.
如果您想引用这篇日记到您的Blog,请复制上面的链接,放置到您发表文章时的相应界面中。

发表评论

Mr Wang

王炜,现在福建泉州从事 B2C 电子商务。爱好编程,业余时间在 FreeBSD / Apache / PHP / PostgerSQL 平台开发 B/S 架构的免费软件。

Follow Google Buzz Twitter Facebook Sina

收藏王炜's Blog

Bookmark and Share

关于此日记

此日记由 王炜 发表于 2009年5月18日 09:17

此Blog上的上一篇日记用onmousemove做拖拽时要注意iframe。

此Blog上的下一篇日记blogspot.com疯了,在解禁的一年之后终于又疯了

首页归档页可以看到最新的日记和所有日记。