I am trying to get a CSS variable into Javascript. I have read the other Stack threads pertinent to this goal, but I am still lost. Please save me from myself.
CSS:
:root {
--loaderSpeed: 100ms;
--loaderDuration: calc(var(--loaderSpeed)*44);
}
JavaScript
setTimeout(() => {
const box = document.getElementById('loaderWrapper');
box.style.display = 'none';
}, 4400);
"4400" needs to be replaced with the variable --loaderDuration
Research indicates that these two are involved:
getComputedStyle(document.documentElement)
.getPropertyValue('--my-variable-name');
...but I have not been able to successfully implement.
Any ideas, Team? Thank you in advance.