I have a root css style file and I have defined some color variables in that. for ex:
--background-blue-primary: #005a9e;
Also, in my main html file there is a button to change theme. when someone clicked on that, i want the color code in variable to change.
how can i do that?
2
Answers
Like this
or
Declare 2 variables as you want.
On clicking a button, just add a custom class "green_theme" to the BODY tag or DIV using Javascript.
If you use jQuery, use below code.
Write the CSS by targeting the ‘green_theme’ class.
Change the Classname (green_theme), Button ID (#addClassButton) and CSS Variables accordingly.