Can someone explain what the document.getElementById("demo")
line does in the example below?
I understand getElementById gets the id of demo but the id is <p id="demo"></p>
What exactly is <p id="demo"></p>
doing in this code?
document.getElementById("age")
is clear as it gets the id of age which is the input.
You're correct in that the document.getElementById("demo")
call gets you the element by the specified ID. But you have to look at the rest of the statement to figure out what exactly the code is doing with that element:
.innerHTML=voteable;
You can see here that it's setting the innerHTML
of that element to the value of voteable
.