Set a new CSS property with "important" priority:
Click the button to set a new CSS property with "important" priority.
<!DOCTYPE html> <html> <head> <style> #ex1 {/*from w w w . ja va 2s. c o m*/ color: red; } </style> </head> <body> <button onclick="myFunction()">Test</button> <div id="ex1">Some text.</div> <script> function myFunction() { var declaration = document.styleSheets[0].cssRules[0].style; var setprop = declaration.setProperty("background-color", "yellow", "important"); } </script> </body> </html>