xxxxxxxxxx
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<h1>template 元素</h1>
<p>点击按钮显示 template 元素中的隐藏内容。</p>
<button onclick="showContent()">显示隐藏内容</button>
<template>
<h2>logo</h2>
<img src="https://atts.w3cschool.cn/attachments/image/20221207/1670380025475113.png" style="width: 400px; height: 400px;" >
</template>
<script>
function showContent() {
var temp = document.getElementsByTagName("template")[0];
var clon = temp.content.cloneNode(true);
document.body.appendChild(clon);
}
</script>
</body>
</html>