使用
$('#contactTemplate').render({name:'haiker', phone:'136'}).appendTo('#tpl');
语法
<script id="template" type="text/html">
<div>
Name:{{=name}}<br/>
{{if phones.length}}
Phone Nubmers;
<ul>
{{each(i,phone) phones}}
<li>{{=phone}}</li>
{{/each}}
</ul>
{{/if}}
</div>
</script>
本文介绍如何利用jQuery模板插件渲染包含姓名和电话号码的联系人信息。通过简单的示例代码展示了如何定义模板及数据,并将数据绑定到HTML元素中。
752

被折叠的 条评论
为什么被折叠?



