How to add styles to an HTML element from a string
•
1 min read
Here the little snippet:
const div = document.createElement('div')
const styles = 'width:100%;background-color:red;'
div.setAtribute('style', styles)