<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>basic-demo</title>
<script src="js/jquery-1.11.3.js"></script>
<script src="plagins/tmpl/jquery.tmpl.js"></script>
</head>
<body>
<table border="1" style="margin:0 auto">
<thead>
<tr>
<th width="10%">ID</th>
<th width="30%">姓名</th>
<th width="30%">数量</th>
<th width="30%">状态</th>
</tr>
</thead>
<tbody id="div_demo">
</tbody>
</table>
<script id="demo" type="text/x-jquery-tmpl">
<tr>
<td>${ID}</td>
<td style="margin-left:10px;">{{= Name}}</td>
<td style="margin-left:10px;">${Number(Num)+1}</td>
<td style="margin-left:10px;">${Status}</td>
</tr>
</script>
<script type="text/javascript">
var users = [
{ ID: '1', Name: '记住你是中国人', Num: '1', Status: 1 },
{ ID: '2', Name: 'Mary Cheung', Num: '2'}
];
$("#demo").tmpl(users).appendTo('#div_demo');
</script>
</body>
</html>
template.png
网友评论