HTML 标签:template
一段 HTML,可以被 JavaScript 克隆并插入。
静态的 template 元素本身不被视为文档的一部分,仅用于被脚本操作。
可选属性
示例
<h3>Optional Attributes</h3>
<table>
<tr>
<th>Attribute</th>
<th>Description</th>
<th>Possible values</th>
</tr>
<template id="row">
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</template>
</table>
<script>
var template = document.querySelector('#row');
for (var i = 0; i < 4; i += 1) {
var clone = template.content.cloneNode(true);
// data-filling gubbins
template.parentNode.appendChild(clone);
}
</script>
