是否有任何解决方法可以使用 <template>
IE 和 Edge 中的元素?
我使用的示例 <template>
元素
<template id="template-comment">
<tr>
<td>
<input type="text" id="input-comment-{ID}-number" name="input-comment-{ID}-number">
</td>
<td>
<input type="text" id="input-comment-{ID}-text" name="input-comment-{ID}-text">
</td>
</tr>
</template>
以及JavaScript对模板的使用
var i = 1;
function NewComment()
{
$("#tbody-comments").append(ReplaceAll($("#template-comment").html(), "{ID}", i++));
}
function ReplaceAll(string, find, replace) { ... }
最佳答案
没有polyfill的解决方案:
而不是 <template>
只需使用 <script type="text/x-html-template">
- 这甚至可以在移动设备的 IE 和 Edge 中使用(这似乎与桌面版 Edge 不同)。
关于javascript - IE 中的模板元素解决方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32056142/