3
How to make this logic within a loop FOR
?
var G1 = $('#G1').text()
var G2 = $('#G2').text()
var G3 = $('#G3').text()
console.log("NaN")
console.log(G1+"\n"+G2+"\n"+G3)
console.log(G1+G2+G3)
G1 = parseFloat(G1)
G2 = parseFloat(G2)
G3 = parseFloat(G3)
console.log("Agora Números")
console.log(G1+"\n"+G2+"\n"+G3)
console.log(G1+G2+G3)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p id="G1">10</p>
<p id="G2">20</p>
<p id="G3">30</p>
Where will you use the values of
G1, G2, etc...
? these elements have a common parent element?– Sergio
What do you want to do more specifically? Not clear enough
– Costamilam
You’re wanting to take the "id" text and do what exactly inside the for??
– Lucas Souza
It’s simply taking the variables of
p
and add. Maniero answered exactly what I needed. Thank you :)– Jackson