Tài liệu HTML DOM createComment()
Ví dụ
Tạo một nút nhận xét và thêm nó vào tài liệu:
const comment = document.createComment("My comments");
document.body.appendChild(comment);
Hãy tự mình thử »Sự miêu tả
Phương thức createComment()
tạo một bình luận và trả về nút bình luận.
Cú pháp
document.createComment( text )
Thông số
Parameter | Description |
text | Optional. The comment text. |
Giá trị trả về
Kiểu | Sự miêu tả |
Nút | Nút nhận xét đã tạo. |
Hỗ trợ trình duyệt
document.createComment()
là tính năng DOM Cấp 1 (1998).
Nó được hỗ trợ đầy đủ trong tất cả các trình duyệt:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | 9-11 |