搜索文档
首页
HTML/CSS
JavaScript
服务端开发
Java教程
移动端
数据库
当前位置:
首页
HTML/CSS
HTML参考手册
HTML 标签大全
源代码
清空
点击运行
<!DOCTYPE html> <html> <body> <h1>HTML template标签的使用(大卫编程网 div.cn)</h1> <p>Click the button to get the content from a template, and display it in the web page.</p> <button onclick="showContent()">Show content</button> <template> <h2>views</h2> <img src="views.png" width="300" height="204"> </template> <script> function showContent() { var temp = document.getElementsByTagName("template")[0]; var clon = temp.content.cloneNode(true); document.body.appendChild(clon); } </script> </body> </html>
运行结果