steevehook
8/22/2018 - 2:33 PM

CSS variables get and set in JS

CSS variables get and set in JS

// Get variable from inline style
element.style.getPropertyValue('--foo');

// Get variable from wherever
getComputedValue(element).getPropertyValue('--foo');

// Set variable on inline style
element.style.setProperty('--foo', 20);