This page was translated from English by the community.Learn more and join the MDN Web Docs community.
Document.head
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since июнь 2018 г..
Возвращает элемент<head> текущего документа. Если имеется более одного элемента<head>, будет возвращён первый из них.
In this article
Синтаксис
var objRef = document.head;
Значение
Пример
<!doctype html><head> <title>Example: using document.head</title></head><script> var theHead = document.head; console.log(theHead.id); // "my-document-head"; console.log( theHead === document.querySelector("head") ); // true</script>Примечание
document.head доступно только для чтения. Присвоить значение этому свойству нельзя. При попытке это сделать ошибка вызвана не будет, только если вы не используетеStrict Mode. В данном случае будет вызваноTypeError .
Спецификации
| Specification |
|---|
| HTML> # dom-document-head-dev> |