如何在 HTML 中为元素添加唯一 ID?
htmlweb developmentfront end technology更新于 2024/7/29 10:52:17
使用 HTML 中的 id 属性为元素添加唯一 ID。
示例
您可以尝试运行以下代码来实现 id 属性 −
<html>
<body>
<h1>Tutorialspoint</h1>
<p id = "myid">We provide Tutorials!</p>
<button onclick = "display()">More...</button>
<script>
function display() {
document.getElementById("myid").innerHTML = "We provide learning videos as well";
}
</script>
</body>
</html>
相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

