2009-06-29 140 views

回答

6

你需要设置样式的基本cssText为folows:

document.getElementById('xx').style.cssText='font-weight:bold; color:#333;'; 
+0

我知道很多,但我从来不知道你可以像设置innerHTML一样设置cssText。很高兴知道。 – joebert 2009-06-29 10:51:09

+2

只是想补充一点,这将重置您与元素xx关联的任何其他样式。 – 2009-06-29 10:51:17

8

可以单独

document.getElementById(obj).style.fontWeight='bold'; 
document.getElementById(obj).style.color='#333'; 
相关问题