I am using CSS variables in my webpage and making a sort of theme color,
:root {
--themeColor: #0afec0;
--hoverColor: #fff;
--bodyColor: #EEF1EF
You can do it in jquery as follows (using the same example of caramba):
$(':root').css('--themeColor', (color = ["red", "green", "lime", "purple", "blue"])[Math.floor(Math.random() * color.length)]);
:root {
--themeColor: orange;
}
a {
color: var(--themeColor)
}
div {
width: 100px;
height: 100px;
background-color: var(--themeColor);
}
Hello world
Test