我正在尝试使用以下内容设置对象的CSS样式:
document.getElementById(obj).style='font-weight:bold; color:#333;';
但它不起作用 . 有谁知道为什么?
你可以分开
document.getElementById(obj).style.fontWeight='bold'; document.getElementById(obj).style.color='#333';
您需要将样式的基础 cssText 设置为folows:
cssText
document.getElementById('xx').style.cssText='font-weight:bold; color:#333;';
文档的样式属性是一个对象,请参考W3school上的HTML DOM Style Object
3 回答
你可以分开
您需要将样式的基础
cssText
设置为folows:文档的样式属性是一个对象,请参考W3school上的HTML DOM Style Object