Modify an existing CSS property:
Click the button to modify an existing CSS property.
<!DOCTYPE html> <html> <head> <style> #ex1 {/* ww w.j a v a 2 s.co 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("color", "blue"); } </script> </body> </html>