I'm trying to set the CSS style of an object with the following:
document.getElementById(obj).style='font-weight:bold; color:#333;';
but it's not working. Does anyone have any idea why?
you can separate
document.getElementById(obj).style.fontWeight='bold';
document.getElementById(obj).style.color='#333';
您需要将样式的基础cssText
设置为以下内容:
document.getElementById('xx').style.cssText='font-weight:bold; color:#333;';
文档的样式属性是一个对象,请在W3school上参考HTML DOM样式对象
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.