Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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');
 
PREVIOUS NEXT
Tagged: #javascript #css #variable
ADD COMMENT
Topic
Name
1+7 =