2
If in the div valor0
have a value, have I get this value in a variable to sum it for example??
In this example we have the div valor0
with value 1, I can send it to test variable?
var teste = document.getElementById("valor0").value;
console.log(teste);
<html>
<div id="valor0"> 1 </div>
</html>
Thanks for your help!! @Sergio
– Sora
Sergio, sorry to bother you, this way has already worked, but I would like to know to study, there is another way to return the value of the div??
– Sora
@Sora you can use i
innerHTML
but if you have HTML it will bring "trash" that you don’t need. You had problems with the answer code, or you have different HTML?– Sergio
So, is that I used this method to take the value of a div and returned the error: Uncaught Typeerror: Cannot read Property 'textContent' of null at ...
– Sora
From what I saw, this error is due to the fact that the script does not find the div or something like
– Sora
@Sora exact. This may be a similar problem to this https://answall.com/q/134810/129 Otherwise I advise you to ask a question, or put a jsFiddle here with an example I can help you with.
– Sergio
Thank you @Sergio !!!!
– Sora