showing results for - "change css variable with javascript"
Sofia
16 Jan 2016
1var root = document.querySelector(':root');
2root.style.setProperty('--variable', 'lightblue');
3/or/
4root.style.setProperty('--variable', myColor); 
Amani
13 Nov 2018
1let docStyle = getComputedStyle(document.documentElement);
2
3//get variable
4let myVarVal docStyle.getPropertyValue('--my-variable-name');
5
6//set variable
7docStyle.setProperty('--my-variable-name', '#fff');
Veronica
20 Oct 2017
1document.documentElement.style.setProperty("--main-background-color", "green");
Morgan
24 Jul 2018
1document.documentElement.style.cssText = "--tab-count: 3";
2/or/
3document.documentElement.style.setProperty("--tab-count", 5);
4/or/
5document.documentElement.setAttribute("style", "--tab-count: 5");
Gwendolyn
21 Mar 2016
1document.documentElement.style.setProperty("--tab-count", 5);
Chantal
22 Jan 2019
1let root = document.documentElement;
2
3root.addEventListener("mousemove", e => {
4  root.style.setProperty('--mouse-x', e.clientX + "px");
5  root.style.setProperty('--mouse-y', e.clientY + "px");
6});
queries leading to this page
set css variables from javascriptpass javascript variable to css variableset js var to cssjs var to cssusing javascript variable in css stylinghow to get a root css varibiblejavascript listen for on change css variable valuehow to get css variable value in javascriptread css variable from javascriptchange css variables jspass a variable from javascript to cssjavascript set and get css variablejavascript change css variable colorjs get css variablersvariable css in javascriptjavascript get and set css variableschange css variable with javascriptvar css jsuse javascript variable in cssget css color variable in javascriptjavascript variable cssretrieve css variable in javascriptupdating css variable with javascripthow to set css variable in javascriptaccessing css variables in javascriptset css var jshow to use a js variable in csschange a css variable in javascriptjavascript set css property variablecreating javascript variables in cssjavascript get computed css varpass javascript variable to csscss variables get value 23 7b 7dstyle css in html with variable javascriptset css variable jsdeclaring css values in variables using jsjs get value of css varhow to access css variable in jscan be alter css variables javascriptchange css var jshow to change css using javascriptjavascript how to set css variable in css methodget css variables of a elemen in jsjavascript set cssvariableadd javascript value as css variablescss variable in javascriptcss variable with javascriptchange css variables using javascripthow to create and set css variable in javascriptset css using javascriptvar root css javascriptget a css variable from javascriptsett css variables with jshow to make js variables with csscss vars set value back to roothow to css variable in jschange the variable css javascriptjs change variables in css fileaccess css variables in jsset css in javascriptsetting scss variables with javascriptuse js value in a css variablehow to change css variables in javascriptget set css variablesdefine css variable in javascriptcss variables change using js change css var in jsjavascript update css variablejq get css variablecss in js variableshow to get change css variable valueset value of css variable with javascriptcant update variable values in cssjavascript output css variablehow to get a css variable in jshow to dynamically change css variable in javascriptcreate css variable in jsusing javascript to create css variablesjavascript read variables from csswrite css in js variableadd css variable to root with javascripthow to cal css variable in javascriptsend variable from js to csshow to get css variables through javascripthow to update css variable with javascript change variable css javascriptget css variable in javascriptpass variable to css from javascriptjavascript use variables in csstypescript change css variablecan you access a css variable in jshow to change css variable value in javascriptcss change variable jshow to change css vars in jsvariables css javascriptuse css variables with javascriptaccess css variable is jschange css variables in javascripthow to set a css variable with javascriptupdate css variable with javascriptacess a css var from jsdom add css variablecan we change css variable in javascriptget and set css variable from javascripthow to grab a css variable with jsget css variables in javascriptget a css variable value in consolehow to use javascript variable in html and css tagsjavascript chage css variblejs change css parameterread variable from css and jshtml set css with javascript variablejs variable into cssgetting variables in js from csscss var added from jschange css with javascript variablechange css property javascriptjavascript output css variable namehow to store a css variable in javascriptget css var in javascriptgetpropertyvalue css variablejs global css variablestyle variable javascripthow to store css in a variable in javascriptchange a css variable with javascripthow to pass a javascript variable to cssjavascript set css varget value of css root variableget css variable from jsscss variable from javascript search resultschange css color var with javascriptcreate and set value of css variable jshow to set a value to a css variable in jshow to create css variable from javascriptlocal css variables update value using jsjavascript get css variabejavascript create css variableset css var with jscontrol css variables from javascripttypescript set css varchange css color variable with javascripthow to add css using jaavascript with variableread css variable in javascriptset variable in js and use in cssadd variable style to css in javascriptset javascript variable in cssget javascript variable in csschanging css variables from jsaccess css variables from javascriptset css variables in javascriptchange css class through javascripthow to change a css variable with javascriptcss variables jsjavascript change css valuecss variables with jshow to change a css variable to another css variable in jscan you use javascript variable in csspass variable to css from jsjavascript get css variable value calculatededit css variables with jsmodify css variables jschange css variables with jsaccess css variables using jsjs set style variableuse js for css variablejavascript on change css variablejavascript read css variablehow to use javascript to edit css variablesjs change css varhot to set a css variable in jsjavascript access css variablescss set variable with jshow to change css var value in javascriptcss variable js acessjavascript set root css variablesjs get css var valuecss variables in jshot to get and set values to css variables in jstypescript css variables htmljavascript modify css variableapply css with javascriptchange css variable with jscss variables with javascripthow to call css variable in javascriptcss variables using javascriptjs set css variableschanging css variable using javascriptcss variable from javascriptpass variable from js to csscss variables change in jshow to set value of css var with jspass variable along to css from javascriptjs variables csshow to change css in javascript using variablejavascript css variableshow to use js variable csshow to use css variables in javascriptjs get css var propertyjs get value of css variablejs get css variabelschange css variable from javascripthow to pass change css with javascriptjs get style varjavascript variables chnage value colorchange javascript variable value html csscss variables javascriptget css root variablecss use javascript variablejs get css variable of elementjavascript use css variablejs change value of css variablechanging css variables with javascriptget js variable in csshow to use css root variables in jsget css value from css variable in javascriptjs set css variable valueuse css variables in java scriptjavascript get css variable 23get css variable value javascriptchnage css variable using javascriptuse css variable in typescriptget javascript variable cssgrab css variable from javascriptjavascript change css property variablechange variable cssget value of css variable in jshow to set variable css in javascriptadd css variable with javascript 3fget css variables javascripthow to get css variable in javascriptset css var from jsjavascript set css attribute variableget root value css javascriptget css var in jsjs get css varstypescript css variableschange css vars with jscss variable value in jsupdating a css variable with javascriptcreate css variable using javascriptcambiar variable css con javascriptjavascript change css vraiablejavascript change css variable valuesaccess css variable in javascriptvariable in css javascriptjs add css variablevariable vale change in css using jscss change variables jsget element css variable jsjavascript change a css variable valuepast css to javascript variablemodify css variable with javascriptcss variables setpropertysetting css variable with javascriptjs get css variablesjavascript set css variabnleaccess and change css variables from jsget css variable from javascripthow to change a css variable in jsjs read css variablehow to change css variable in jsget a css var in jsvariable into css jsuse js variables on cssjs get variable in csschange css with javascriptcss var to jsjs get root propertieschange css variables javascriptjs set root css variableset css variable using javascriptjavascript how to get the value of css variablecss variables manipulate with jsscript get css variablehow to use varibles with chageing css in javascriptsee css var with jshow to create a css variable jsget css variable in jshow to access css variable in javascriptget css variable programmaticallyadd new css variable with javascriptcss get value as variablecss variable with jsset css var functon value using javascriptjavascript change color of css varjs get root stylejs css modify a css varjavascript 3a edit css variablehow to use css var in javascriptchanging css variable with javascriptmanipulating css variables with javascriptvariables in css from javascriptjavascript to html or css variablesusing javascript to get 2fset css custom variablesset global css variable javascripthow to put js variable in csschange css custom variables with jscs s change in javascript on variablejs set css variable with scopeusing javascript to set css varscss variables from jshow to change a css variable through javascriptcss variables can be changed with javascript usingset css property to variableusing css variables in javascriptcss variables from javascriptget css var ibn jscss set js var colorset css varialbe jscss variables get valuejavascript variable in css stylejs variable as css colorhow to set the value of custom css variables in jsjavascript set css root variableuse javascript variable cssjs update css variablecss variables javascript applyjavascript apply css to element variablehow to select css variable in javascriptchange css variable using javascripthow to use typescript variable in csschange css variables from jshow to change value of css variables from javascriptcss var using jsaccess css variables in htmlchaange css variblw jsjavascript get css variable value in jshow to change value in variable csscss get variable from javascriptjs select css variablescan i assign css variables with jsuse global css variable in javascripthow to change and use css variables in javascriptdoes changing css var update stulejavascript edit css variablehow to create a variable in css in jschange root values css javascriptcss variable change with javascriptjavascript get value of css varcss var change color javascriptcss js variablechange variable of css in js javascript css variablejavascript css variables changecahge css varible with javascripthow to read css variable in javascripthow to change css variable in javascript by idjavascript set css variablescan you update a css variable to another css variable with jsget var css value javascriptjavascript get root css variablesend a variable from cs to javascriptpass a variable to css from jscss work with js variableshow to change css variables using javascriptpass value to css variable from javascriptget variable from css in javascriptjavascript set css variable valuehow to get css varibals in jget css element value in variable jsadd css variable with javascripthow to edit javascript variable in cssupdate js var by getting css propertyjs get var from cssset variable css javascriptjavascript get css variable colordocument documentelement style getpropertyuse javascript variable in css stylejavascript add css variable to elementvariable css javascriptchange css variable from jsdefine css variable javascriptjs edit css variablejs change css varsget the css variable names from javascriptgetcomputedstyle 3aroot javascriptcss set variable in javascriptcan i use css variables in jsshow to use js variables in cssset css variable with javascripthow to apply css to variable inside html in javascriptchange css variables with javascriptadd javascript variable value to cssjavascript print css variablecss variables change javascriptcan i pass a variable from javascript to cssuse css variable in jshow to pass a javascript variable in css stylechange css var in html with javascriptrequire css variables javascripthow to get variable value from javascript to cssjs set css varchange the root vars in css bby jscan css access javascript variabledocument styles set css variableshow to set css variables jschange value of css variable with jshow to set a css variable javascriptjs get css varchange css variable value javascriptchange css with jsget values of vars csshow to change css var by jsadd css to variable in jshow to define css varible in jscss read javascript variablejs variable in cssfill css variable from javascripthow to access javascript variable from cssget css variable value in javascriptcss variables in es6javascript change all css variables with namejs create css variablechange css value with javascriptcss var from javascripthow to use javascriipt variable in csscss set variable fmo jshow to use css variables in jsjs modify css variablehow to access css variables in javascripthow to use variables from css to jsupdate css custm property in tsjavascript styling root variablejavascript change style varjs change css variable valuejs change css variablejs set css variablejs change css colour variableupdate css variable byset css variable via javascripthow to give css color in variable javascripthow to change a css value with javascriptmodify css class with javascriptchange css var using javascripthow to get var css in jsset css variables typescripthow to change css var in javascriptget value of root variable javascripthow to give javascrpit variables csshow to change css variablec with javascriptwrite html and css in js variablechange css varaibles in jsadd css var with jshow to get value of css variable in javascriptjavascript write css variablehow to style javascript variables in csshow to create variables css in jsjs dom access css varhow to call css variables in jshow to set js variable into cssi have javascript variable i wanna set it to css propertycss variables getpropertyvaluejs define css variablehow to change variable in css with jsjs set variable in cssget root variable javascriptget css variable jshow to make a variable in javascript that i can reference in cssupdate css variable from jschange css var with javascriptpass a variable from js to cssjavascript variable in cssjavascript to css variablecan css chnage variables in jshow to control css variables with javascriptget css variables for javascriptcss variables in javascripthow to change var in css by jsset css variable from javascriptcss variable get value from javascriptuse css variables in javascripthow to get css root variables in jsjavascript get css varshow to get css variable in jschange css variable javascriptchange javascript variable with csscan you change css variable in javascripthow to change css variable using jsjavascript how to set css variablejavascript add variable to cssget property javascript css variablehow to change value in variable css in javascripthow to change value of css variable in javascriptcss variable javascriptjs manipulate css variablejavascript change css variable valuehow to inject value to css variable in jsvar pxhow to change the css variable in javascriptvariables in css javascriptcss style variable javascriptupdate css variable javascriptvariables from javascript to cssjs css variablechanging css var with jsset css vars jschange css variable in javascriptjavascript change css variableget css variablehow to access css variables in javascriotjs changes css varhow to store css value in js variablehtml javascript set style as variableget css variable with javascriptjs change css variableshow to assign a css file to a variable in javascriptupdate css variables with jscss variables update jsjavascript get css variablejavascript get css varjs get css variable valuecreate css variable with javascriptaccessing variable from css in javascriptchange var css with jsdefine css variables in javascriptcss set variable javascriptjs get css root variablesetting css variables with javascripthow to access a js variable in css filehow to set a css variable in javascriptjavascript get value of css variableaccess css variable from jswrite varable into set property stile in jscss variable in jsjavascript add css variableuse javascript variables in cssvar css in jsuse css variable in javascriptjs define css variablescss custom variable jshow to change variable in css using javascriptusing javascript to create css custom variableshow to get a css variable with jsset css variable javascriptget value of css variable javascriptpass css variable to javascriptjs observe css variable changehow to use js variable in cssjs get var cssvariable value change in css using jsjs access to css variablescss javascript variablesupdate css variables with javascriptcontrol css variables with jshow to change css variable in javascripthow to get a variable from css in javascripytypescript get css variablechange css value jsaccessing css variables in jsget css variable javascriptcss var jsjava change css variable valueget variable css on jscan you use js to overwrite css variablesuse js value in a css variable guidecss variables access from javascripthow to get and set css variable value with javascripthow to change css based on javascript variablegetcomputedstyle 28document documentelement 29 getpropertyvalue 28 27 23 27 29set css var with javascriptjavascript edit css variablesget css variable value jsget css variables via jscss variables can be changed with javascript using 3fset css variables typescript on specific elementjavascript apply css variable to elementchange css variable value with javascriptjs css custom variableuse js variable in csschange css variables in jsfetch root property jsset css variable value from javascriptget css variables in jsadding js variable in cssset css variable from javascript on clickjavascript get css var valueupdate css variables javascriptjavascript set color to css variablesave css color to js variablehow to chage value of css variable in jshow to get a custom variable from css in jscan i change the value of variable in css using jsjavascript pass variable to cssget css variable value in jshow to change css variables with jshow to influence css variables in javascripthow to accesss css variable in javascriptjavascript dom css variableuse js to change css variablesjavascript set css variablees6 set style variableextract the value from css variableget css global vars javascriptchange css property using javascriptchanging values of css variables using jsset css variable in jsset variables in css jsjs get css variablecustom css variable jschange css variable jscss variable jsedit css variables javascriptjs css variablesjavascript write css variable nameaccess css variables in javascriptjavascript access css variablechange global css variable with javascriptchange css variable with javascript