gpt4 book ai didi

Javascript getElementById?

转载 作者:行者123 更新时间:2023-11-28 13:47:24 25 4
gpt4 key购买 nike

很难说出这里问的是什么。这个问题是模棱两可的、模糊的、不完整的、过于宽泛的或修辞的,无法以目前的形式得到合理的回答。如需帮助澄清这个问题以便重新打开它,visit the help center .




9年前关闭。




我正在尝试查找 `document.getElementById.??? 的可能选项列表。有谁知道我在哪里可以找到可以给我所有可能选项的列表?

我已经无数次地搜索了谷歌。我只想知道getelementbyid之后的所有选项。

最佳答案

对于诸如此类的问题,尤其是如果您是 JavaScript 新手,我建议您查看 Mozilla Developers Network.

在这种情况下,可以在MDN上找到您需要的信息here .这是您会发现的内容的预览(直接取自 MDN):

Summary

Returns a reference to the element by its ID.

Syntax

element = document.getElementById(id);

where

  • element is a reference to an Element object, or null if an element with the specified ID is not in the document.
  • id is a case-sensitive string representing the unique ID of the element being sought.

Example


<!DOCTYPE html>
<html>
<head>
<title>getElementById example</title>
<script>
function changeColor(newColor) {
var elem = document.getElementById("para1");
elem.style.color = newColor;
}
</script>
</head>
<body>
<p id="para1">Some text here</p>
<button onclick="changeColor('blue');">blue</button>
<button onclick="changeColor('red');">red</button>
</body>
</html>

关于Javascript getElementById?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13257696/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com