I've got this code:
let myId = document.getElementById('myID');
myId.style.backgroundColor = 'black';
myId.style.color = 'green';
Is there a way to group all css code in one group omitting the "myId.style" prefix? Like in {}?
I've got this code:
let myId = document.getElementById('myID');
myId.style.backgroundColor = 'black';
myId.style.color = 'green';
Is there a way to group all css code in one group omitting the "myId.style" prefix? Like in {}?
You can do it like this:
myId.style.cssText = "display: block; position: absolute";
or maybe with es6 like this:
myId.style.cssText = ```
display: block;
position: absolute;
```
This question was already mentioned here: https://stackoverflow.com/a/3968772/3865116