document.setAttribute
问题 Can this be used to change CSS? Cant see much on w3 about it. Anyone know anything about it. If this forum/site isnt the place for asking browser standard questions, can someone point me in the right direction? Thanks --Mark 回答1: Yes, you can use setAttribute to change the CSS of a single DOM element, like so: document.getElementById("something").setAttribute("style", "color: red;"); However, I believe it's bad practice. You can modify the stylesheet as Marius pointed out by doing: document