DOM là gì?
Document Object Model cho phép JavaScript truy cập và thao tác phần tử HTML.
Các phương thức chính
- getElementById(), querySelector().
- addEventListener() để xử lý sự kiện.
Ví dụ
document.getElementById("btn").addEventListener("click", function() {
alert("Bạn vừa click!");
});
Kết luận: Nắm DOM để xây dựng tương tác web hiệu quả.