Answers for "add style js without overwrite"

0

add style js without overwrite

// Bad
element.setAttribute("style", "background-color: red;"); 
// Good
element.style.backgroundColor = "red";
Posted by: Guest on February-19-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language