Document: thuộc tính head
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since June 2018.
Thuộc tính chỉ đọc head của giao diện Document trả về phần tử <head> của tài liệu hiện tại.
Giá trị
Một HTMLHeadElement.
Ví dụ
html
<!doctype html>
<head id="my-document-head">
<title>Ví dụ: sử dụng document.head</title>
</head>
js
const theHead = document.head;
console.log(theHead.id); // "my-document-head";
console.log(theHead === document.querySelector("head")); // true
Ghi chú
document.head là chỉ đọc. Cố gắng gán giá trị cho thuộc tính này sẽ thất bại âm thầm hoặc, trong Strict Mode, ném ra TypeError.
Đặc tả kỹ thuật
| Specification |
|---|
| HTML> # dom-document-head-dev> |