Sử dụng id trong HTML để thêm id duy nhất của một phần tử.
Ví dụ
Bạn có thể thử chạy mã sau để triển khai id thuộc tính -
<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>