HTMLTemplateElement.content

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since November 2015.

HTMLTemplateElement.content 属性返回 <template> 元素的模板内容(一个 DocumentFragment)。

语法

var documentFragment = templateElement.content

示例

js
var templateElement = document.querySelector("#foo");
var documentFragment = templateElement.content.cloneNode(true);

规范

Specification
HTML Standard
# dom-template-content-dev

浏览器兼容性

BCD tables only load in the browser

相关链接