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?
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 need to set the underlying cssText
of the style as folows:
document.getElementById('xx').style.cssText='font-weight:bold; color:#333;';
you can separate
document.getElementById(obj).style.fontWeight='bold';
document.getElementById(obj).style.color='#333';
Document's style property is a object, please reference HTML DOM Style Object on W3school