Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to change a css variable with javascript

var root = document.querySelector(':root');
root.style.setProperty('--variable', 'lightblue');
/or/
root.style.setProperty('--variable', myColor); 
 
PREVIOUS NEXT
Tagged: #change #css #variable #javascript
ADD COMMENT
Topic
Name
2+3 =