What's the difference between document.getElementById(“test”).value and document.getElementById(“test”)[removed]

后端 未结 5 1886
心在旅途
心在旅途 2021-01-01 00:37
document.getElementById(\"test\").value

document.getElementById(\"test\").innerHTML

Does the first mean the address and the second mean the value

5条回答
  •  梦谈多话
    2021-01-01 01:17

    Many elements in HTML can have an ID, so the definition of value will change for each.

    value will be essentially what that element understands as a value. For example, an would give you the text inside.

    innerHTML will be what HTML code is inside. For example, a would have its child TD's, plus whatever else is in there.

    value and innerHTML can (usually) be written to, as well as read.

提交回复
热议问题