0
<h1>Somando Valores</h1>
<input type="number" name='txtn1' id="txtn1"> +
<input type="number" name="txtn2" id="txtn2">
<input type="button" value="Somar" onclick="somar()">
<div id="res"> Resultado</div>
function somar() {
var n1 = Number.parseFloat(window.document.getElementById('txtn1'))
var n2 = Number.parseFloat(window.document.getElementById('txtn2'))
var res = window.document.getElementById('res')
var s = n1 + n2
res.innerHTML = `A soma entre ${n1} e ${n2} é igual a ${s}`
}
</script>
Why can’t I do that?
In this case you would have to open a variable to the cont
Who cont? Your question is not clear!
– LeAndrade
Why can’t I do that? In this case you would have to open a variable for the contents of <imput> and then open another variable by placing it inside, like this:
– Pedro Raul
Function somar() { var txt1= window.document.getElementById('txtn1') var txt2= window.document.getElementById('txtn2') var res = window.document.getElementById('res') var n1 = Number(txt1.value) var N2 = Number(txt2.) var s = n1 + N2 res.innerHTML =
A soma entre ${n1} e ${n2} é igual a ${s}
– Pedro Raul
Edit your question in more detail to give you a more direct answer, so you can’t understand what you want.
– user181348