2
I want to define the Progress css via java script, making it change with a value I put in the Html input. take a look:
HTML:
<link rel="stylesheet" type="text/css" href="HPCSS.css">
</head>
<div class="teste"></div>
<input id="vida" onchange="update()">
<script type="text/javascript" src="HPJS.js"></script>
CSS:
.teste{
--progess:2000;
height: 50px;
padding: 5px;
background-color: #ccc;
display: flex
}
.teste::before{
content: "";
width: calc(var(--progess)*1%);
background-color: red
}
Javascript:
function update(){
var vida= document.getElementById("vida")
var value= vida.value
}
I already passed the input value pro JS, now I want to know how to define this value as value of the variable Progress in CSS Who can help me I would appreciate
use the style property:
document.querySelector(".teste").style["progress"] = valor;
– Ricardo Pontual
It didn’t work out
– Pedro Henrique