1. 面向开发者的 Web 技术
  2. Web API
  3. HTMLTemplateElement
  4. HTMLTemplateElement.content

此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

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 ⁨2015年11月⁩.

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

语法

var documentFragment = templateElement.content

示例

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

规范

Specification
HTML
# dom-template-content-dev

浏览器兼容性

相关链接

Help improve MDN

Learn how to contribute

This page was last modified on by MDN contributors.

AltStyle によって変換されたページ (->オリジナル) /