jquery 中的tmpl类似于asp.net中的datalist控件。

首选,在页面代码中加入两行,jquery的js文件引用

<script src="http://code.jquery.com/jquery-latest.min.js"></script>

<script src="http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"></script>

 然后再建一个html模版

<script >

<li><b>${Name}</b>(${ReleaseYear})</li>

</script>

 

<script >

var moives=[{Name:"The Red Violin",ReleaseYear:"1998"},{Name:"Eyes Wide Shut",ReleaseYear:"1999"},{Name:"The Inheritance",ReleaseYear:"1976"}];//获得json格式的数据

$("#moiveTemplate").templ(moives).appendTo("#moiveList");

</script>

 

<ul >

</ul>

 效果显示为:

  • The Red Violin (1998)
  • Eyes Wide Shut (1999)
  • The Inheritance (1976)

相关文章:

  • 2021-11-11
  • 2021-08-18
  • 2021-10-18
  • 2022-12-23
猜你喜欢
  • 2021-10-12
  • 2022-03-02
  • 2022-12-23
  • 2021-12-19
相关资源
相似解决方案