`
Luob.
  • 浏览: 1572307 次
  • 来自: 上海
社区版块
存档分类
最新评论

Jquery template 小demo

阅读更多
<!DOCTYPE html> 
<html> 
<head> 
  <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> 
</head> 
<body> 
   
<ul id="movieList"></ul> 
 
<script> 
  var movies = [ 
  { Name: "The Red Violin", ReleaseYear: "1998" }, 
  { Name: "Eyes Wide Shut", ReleaseYear: "1999" }, 
  { Name: "The Inheritance", ReleaseYear: "1976" } 
  ]; 
 
var markup = "<li><b>${Name}</b> (${ReleaseYear})</li>"; 
 
/* Compile the markup as a named template */ 
$.template( "movieTemplate", markup ); 
 
/* Render the template with the movies data and insert 
   the rendered HTML under the "movieList" element */ 
$.tmpl( "movieTemplate", movies ) 
  .appendTo( "#movieList" ); 
</script> 
 
</body> 
</html>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics