set css variable from javascript
let docStyle = getComputedStyle(document.documentElement);
//get variable
let myVarVal docStyle.getPropertyValue('--my-variable-name');
//set variable
docStyle.setProperty('--my-variable-name', '#fff');document.documentElement.setAttribute("style", "--main-background-color: green");document.documentElement.style.cssText = "--tab-count: 3";
/or/
document.documentElement.style.setProperty("--tab-count", 5);
/or/
document.documentElement.setAttribute("style", "--tab-count: 5");document.documentElement.style.setProperty("--main-background-color", "green");
Also in JavaScript:
- onclick timer javascript
- nodejs include json file
- react js documentation
- node js to check 32 bit
- react mid senior dev interview questuions
- push array javascript
- are you sure you want to proceed click ok button javascript code
- remove array elements javascript
- math.random js
- bootstrap in javascript
- convert date format from yyyy-mm-dd to dd-mm-yyyy using value javascript
- saveas angular 6
- react native image fit container
- javascript get div x y position
- get page link angular
- setinterval javascript
- how to check if object exists in javascript
- online javascript compiler
- p5 js functions
- vue js on checkbox show div
- javascript foreach in object
- jquery click event
- json-server localhost
- dropdown option selection change event in jquery