jQueryTemplate的用法

Javascript代碼中不要包含HTML:

創(chuàng)新互聯(lián)-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價(jià)比師宗網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式師宗網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋師宗地區(qū)。費(fèi)用合理售后完善,十余年實(shí)體公司更值得信賴。

var div = document.getElementById("my-div");
div.innerHTML = "<h4>Error</h4><p>Invalid e-mail address.</p>";

在Javascript代碼中完全隔絕HTML很難,這一點(diǎn)可以根據(jù)實(shí)際情況來權(quán)衡使用。Javascript 模版技術(shù)就是一種有效隔離HTML和Javascript代碼的手段,如下是jQuery Template的用法:

// HTML<script id="bookTemplate" type="text/x-jQuery-tmpl">  <div>      <img src="BookPictures/${picture}" alt="" />      <h3>${title}</h3>      price: ${formatPrice(price)}  </div>
 </script>// Javascript// Create an array of booksvar books = [{ title: "ASP.NET 4 Unleashed", price: 37.79, picture: "AspNet4Unleashed.jpg" }];// Render the books using the template$("#bookTemplate").tmpl(books).appendTo("#bookContainer"); 
function formatPrice(price) {      return "$" + price.toFixed(2);
}

網(wǎng)頁標(biāo)題:jQueryTemplate的用法
當(dāng)前URL:http://muchs.cn/article48/gpjeep.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供做網(wǎng)站、外貿(mào)建站、營銷型網(wǎng)站建設(shè)建站公司、外貿(mào)網(wǎng)站建設(shè)品牌網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站優(yōu)化排名