Use of document.getElementById in JavaScript

后端 未结 7 1002
后悔当初
后悔当初 2021-02-06 08:31

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

7条回答
  •  有刺的猬
    2021-02-06 09:15

    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.

提交回复
热议问题