0
I have this code:
function convert() {
var bord = window.document.getElementById("borda")
var b = Number(bord.value)
document.getElementById("caixa").style.widht = "10px"
}
<div id="caixa" style="width: 100px; height: 100px; background-color: blue;"></div>
<form>
<input id="borda" name="borda" type="number">
<input type="button" value="BOTÃO" onclick="convert()">
</form>
By clicking the button the element does not change size.
If you just want to solve the immediate problem:
document.getElementById('idDoElemento').style.width = "200px";
– Bacco
I’m a beginner, but follow the code there <div id="box" style="width: 100px; height: 100px; background-color: blue;"></div> <form> input id="edge" name" type="number"> <input type="button" value="BUTTON" onclick="Convert()"> </form> <script> Function Convert() { var Bord = window.document.getElementById("edge") var b = Number(Bord.value) Document.getElementById("box").style.widht = "10px" } </script>
– user178852
to get the width
var largura = window.document.getElementById("borda").value
. If you don’t have the "px" in it you need alargura = ( largura + 'px' );
. then use the variable instead of 200px in my example.– Bacco