如何在 HTML 中为元素添加唯一 id?
使用 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>
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
JavaScript
PHP