Use of document.getElementById in JavaScript

后端 未结 7 1017
后悔当初
后悔当初 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-06 09:17

    getElementById returns a reference to the element using its id. The element is the input in the first case and the paragraph in the second case.

    https://developer.mozilla.org/en-US/docs/Web/API/document.getElementById

提交回复
热议问题