DOM Properties
HTMLTemplateElement.content
Read-only object reference. Exposes the inert contents of an ordinary template. Clone or import the fragment before appending if the original is intended to remain reusable. Appending the original fragment moves its children out. Example result: Saved.
Formal Syntax & Structure
html syntaxhtml
element.contentReturn Value
DocumentFragment
Property value. Read-only object reference.
Working Example
Example Snippethtml
<template id="demo"> <p>Saved</p></template><p> Result: <output id="result"></output></p><script> const e = document.getElementById('demo'); const result = value => { document.getElementById("result").textContent = String(value); }; const copy=document.importNode(e.content,true); result(copy.firstElementChild.textContent);</script>