Home > front end >  How do I get --value from document.getElementById("id").style?
How do I get --value from document.getElementById("id").style?

Time:05-19

<div id="progbar" role="progressbar" aria-valuenow="33" aria-valuemin="0" aria-valuemax="100" style="--value: 33"></div>

I need to get the "--value" here.

document.getElementById("progbar").style.value
document.getElementById("progbar").style.--value

I tried these but it didn't work, how can I get this value? Note: I'm working on Arduino

CodePudding user response:

The solution to retrieve it, is to use :

getComputedStyle(document.getElementById("progbar"))
    .getPropertyValue('--value');

i found the solution here : https://davidwalsh.name/css-variables-javascript

you can also set the value :

document.getElementById("progbar").style
    .setProperty('--value', 'pink');
  •  Tags:  
  • html
  • Related