我有一个下面的div元素:
<div style="color:#0000FF">
<h3>This is a heading</h3>
<p>This is a paragraph.</p>
</div>
有没有办法使用JavaScript更改此div标记的样式属性?
具体来说,我想要做以下事情:
将此样式属性设置为另一个字符串,例如style="test"
创建一个新的样式属性,并用新的属性替换此属性
即:
var new_style_a = document.createAttribute("style");
(somehow insert this new attribute into the div tag)