Document.head
La proprietà head
di sola lettura dell'interfaccia Document
restituisce l'elemento <head>
del documento corrente.
Sintassi
var objRef = document.head;
Valore
Un HTMLHeadElement
.
Esempio
<!doctype html>
<head id="my-document-head">
<title>Esempio: usare document.head</title>
</head>
<script>
var theHead = document.head;
console.log(theHead.id); // "my-document-head";
console.log( theHead === document.querySelector("head") ); // true
</script>
Appunti
document.head
è di sola lettura. Cercare di assegnare un valore a questa proprietà fallirà silenziosamente o, in Strict Mode, genera un TypeError
.
Specifiche
Specifica | Stato | Commento |
---|---|---|
HTML 5.1 The definition of 'Document.head' in that specification. |
Recommendation | |
HTML5 The definition of 'Document.head' in that specification. |
Recommendation | |
HTML Living Standard The definition of 'Document.head' in that specification. |
Living Standard | Definizione iniziale. |
Compatibilità con i browser
BCD tables only load in the browser