0

I have this css:

body {
    --animation: terminal-bar;
    --size: 1.4;
}

how can I get value of --animation in JavaScript?

I've tried this:

getComputedStyle(document.body)['--animation'];
document.body.style.getPropertyValue('--animation');

they both don't work, I've found this in developer tools:

document.body.computedStyleMap().get('--animation')[0]

but according to MDN it's suppored only in Chrome.

Is there relatively Cross-Browser solution (it don't need to work in IE) where you can get value of css variable set in css style sheet?

jcubic
  • 61,973
  • 54
  • 229
  • 402

0 Answers0