Document: thuộc tính firstElementChild
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2018.
Thuộc tính chỉ đọc Document.firstElementChild trả về Element con đầu tiên của tài liệu, hoặc null nếu không có phần tử con nào.
Đối với tài liệu HTML, đây thường là phần tử con duy nhất, phần tử gốc <html>.
Xem Element.firstElementChild cho phần tử con đầu tiên của các phần tử cụ thể trong tài liệu.
Giá trị
Một đối tượng Element, hoặc null.
Ví dụ
js
document.firstElementChild;
// trả về phần tử <html> gốc, phần tử con duy nhất của tài liệu
Đặc tả kỹ thuật
| Specification |
|---|
| DOM> # ref-for-dom-parentnode-firstelementchild①> |