Web APIs

HTMLTemplateElement.content

Try the free JavaScript compiler

Returns the DocumentFragment storing the template contents.

Formal Syntax & Structure

javascript syntaxjavascript
template.content

Return Value

DocumentFragment

Returns the DocumentFragment storing the template contents.

Working Example

Example Snippetjavascript
(async () => {const t=document.createElement("template");t.innerHTML="<span>ready</span>";document.body.append(t);console.log(t.content.querySelector("span").textContent,document.querySelector("span")===null);})()
JavaScript Reference