Created
May 16, 2020 17:34
-
-
Save nmanikiran/74941da50457fa68b448e0ce0d6b6403 to your computer and use it in GitHub Desktop.
Update CSS variables with javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var root = document.querySelector(':root'); | |
var rootStyles = getComputedStyle(root); | |
var red = rootStyles.getPropertyValue('--red'); | |
console.log('red: ', red); | |
root.style.setProperty('--red', 'green') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment