<div class="codetitle"> <span><a style="CURSOR: pointer" data="74073" class="copybut" id="copybut74073" onclick="doCopy('code74073')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code74073"> <br> <br><br><h1>天地盟主 QQ:467713292</h1> <br><br><!-- 将模版放置的位置标签 --> <br><div id="contactContainer"></div> <br><br><!-- 定义模板的内容布局 和定义显示的字段 --> <br><script id="contactTemplate" type="text/html"> <BR><div> <BR>姓名: {{= name }} <br /> <BR>手机号: {{= phone }} <BR></script> </div> <br> <br>//引用两个js <br> <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="65787" class="copybut" id="copybut65787" onclick="doCopy('code65787')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code65787"> <br><script src="Scripts/jquery-1.4.2.js" type="text/javascript"></script> <br><script src="Scripts/jquery.tmpl.js" type="text/javascript"></script> <br><script type="text/javascript"> <br><br>var contacts = [ <BR>{name:"天地盟主", phone:"467713292"}, <BR>{name:"与狼共舞", phone: "206-555-7878" }, <BR>{name:"程序员中的菜鸟", phone: "415-555-8888" } <BR>]; <br><br>//只需要这样一句话就可以将上面定义好的json数据填充到模板里 呈现出来 <BR></script> </div> <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="43761" class="copybut" id="copybut43761" onclick="doCopy('code43761')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code43761"> <br>$("#contactTemplate").render(contacts).appendTo("#contactContainer"); <br> <br> <br> </div>