Typically, for styles that have to be applied dynamically to HTML objects with JS, we set it as an attribute using "setAttribute()"
What about this "outline" CSS property? How can I set that onto an object with JS? Unless there is a way to dynamically add CSS to the document?
Typically, for styles that have to be applied dynamically to HTML objects with JS, we set it as an attribute using "setAttribute()"
What about this "outline" CSS property? How can I set that onto an object with JS? Unless there is a way to dynamically add CSS to the document?
Share Improve this question asked Jun 7, 2009 at 5:51 Robin RodricksRobin Rodricks 114k147 gold badges414 silver badges617 bronze badges1 Answer
Reset to default 10You can change most CSS values using the following code:
document.getElementById('idofelement').style.outline='value';
or
object.style.cssproperty='value';
Here is what W3 has to say about it.