<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><br> <br> <br><br><h1>天地盟主QQ1> :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 }} </script> </div> <br> <div class="codetitle">//引用兩個js <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><br> 程式碼如下:<br><br> <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" } </script> </div>]; <br><div class="codetitle">//只需要這樣一句話就可以將上面定義好的json資料填入範本呈現<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><br> 程式碼如下:<br><br> </div> 程式碼如下: 程式碼如下: 程式碼如下:$("#contactTemplate").render(contacts).appendTo("#contactContainer");