私はこのようなものを作成したい:
<table>
<tr>
<td><div><font>ID</font></div></td>
<td><div><font>Name</font></div></td>
</tr>
</table>
私はこのようなものを作成したい:
<table>
<tr>
<td><div><font>ID</font></div></td>
<td><div><font>Name</font></div></td>
</tr>
</table>
Javascript に HTML を含めるのは好きではないので、テンプレートで jQuery を使用する方法を次に示します。
私のHTMLで:
<script id="hidden-template" type="text/x-custom-template">
<tr>
<td><div><font>ID</font></div></td>
<td><div><font>Name</font></div></td>
</tr>
</script>
私のJavascriptで:
var template = $('#hidden-template').html();
$('.add').click(function() {
$('#targetTable').append(template);
});
クラス「追加」のボタンがあり、テンプレートからHTMLを追加します<table id="targetTable">