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?
Share Improve this question edited Jun 29, 2009 at 10:45 paxdiablo 884k241 gold badges1.6k silver badges2k bronze badges asked Jun 29, 2009 at 10:12 ZA.ZA. 10.5k10 gold badges38 silver badges39 bronze badges3 Answers
Reset to default 8you can separate
document.getElementById(obj).style.fontWeight='bold';
document.getElementById(obj).style.color='#333';
You need to set the underlying cssText
of the style as folows:
document.getElementById('xx').style.cssText='font-weight:bold; color:#333;';
Document's style property is a object, please reference HTML DOM Style Object on W3school
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744845375a4596802.html
评论列表(0条)