Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I apply the "outline" CSS property with JavaScript?

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?

like image 924
Robin Rodricks Avatar asked Sep 08 '25 14:09

Robin Rodricks


1 Answers

You 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.

like image 82
Sam152 Avatar answered Sep 10 '25 05:09

Sam152