x
 
<!DOCTYPE html>
<html>
<body>
<h1>template 元素</h1>
<p>单击下面的按钮,显示 template 元素中的隐藏内容。</p>
<button onclick="showContent()">显示隐藏的内容</button>
<template>
  <h2>Flower</h2>
  <img src="/i/photo/flower.gif" width="180" height="180">
</template>
<script>
function showContent() {
  var temp = document.getElementsByTagName("template")[0];
  var clon = temp.content.cloneNode(true);
  document.body.appendChild(clon);
}
</script>
</body>
</html>