Search
 
SCRIPT & CODE EXAMPLE
 

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); 
Comment

javascript get css variable

let docStyle = getComputedStyle(document.documentElement);

//get variable
let myVarVal docStyle.getPropertyValue('--my-variable-name');

//set variable
docStyle.setProperty('--my-variable-name', '#fff');
Comment

javascript get css variable

getComputedStyle(document.documentElement)
    .getPropertyValue('--my-variable-name'); // #999999
Comment

how to change css variable in javascript

document.documentElement.style.setProperty("--main-background-color", "green");
Comment

set css variable from javascript

document.documentElement.style.cssText = "--tab-count: 3";
/or/
document.documentElement.style.setProperty("--tab-count", 5);
/or/
document.documentElement.setAttribute("style", "--tab-count: 5");
Comment

how to change css variable in javascript

document.documentElement.setAttribute("style", "--main-background-color: green");
Comment

js set css variable

document.documentElement.style.setProperty("--main-background-color", "green");
Comment

how to set css variables in javascript

		const docStyles = document.documentElement.style;

		docStyles.setProperty('--accent', '#ffffff');
		docStyles.setProperty('--textColor', '#ffffff');
Comment

how to change css variable in javascript

document.documentElement.style.cssText = "--main-background-color: red";
Comment

PREVIOUS NEXT
Code Example
Javascript :: shorthand for jquery document ready 
Javascript :: sleep in react 
Javascript :: get text selected option jquery 
Javascript :: disable anchor tag jquery after click 
Javascript :: from milliseconds to hours in js 
Javascript :: chartjs how to disable animation 
Javascript :: fetch get authorization header 
Javascript :: get select2 selected value 
Javascript :: delete with unlinksync node 
Javascript :: getthe array length of jsonb object postgres 
Javascript :: js alert and redirect 
Javascript :: best way to detect mobile device jquery 
Javascript :: jquery add option to select 
Javascript :: disable scroll jquery 
Javascript :: jquery style display 
Javascript :: enzyme adapter react 17 
Javascript :: Your global Angular CLI version (11.0.2) is greater than your local version 
Javascript :: update node to latest version 
Javascript :: put form action jquery 
Javascript :: react native android build 
Javascript :: how to clear inner html using jquery 
Javascript :: play background music in html jasvascript 
Javascript :: iframe in react native 
Javascript :: js extract domain from email 
Javascript :: how to redirect programatically in nextjs 
Javascript :: write file with deno 
Javascript :: regex email js 
Javascript :: how to math 
Javascript :: change firebase region 
Javascript :: js preventdefault 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =