jQuery模板可以绑定到原始数​​组

前端之家收集整理的这篇文章主要介绍了jQuery模板可以绑定到原始数​​组前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
特定
  1. <div id="place_holder" />
  2.  
  3. <script id="template" type="text/x-jquery-tmpl">
  4. WHAT DO I PUT HERE
  5. </script>
  6.  
  7. var array_of_ints = [1,2,3]
  8.  
  9. $( "#template" )
  10. .tmpl( array_of_ints )
  11. .appendTo( "#place_holder" );

我可以在模板中添加什么?

  1. <ul>
  2. <li>1</li>
  3. <li>2</li>
  4. <li>3</li>
  5. </ul>

解决方法

  1. <ul id="place_holder">
  2. </ul>
  3.  
  4. <script id="template" type="text/x-jquery-tmpl">
  5. <li>${}</li>
  6. </script>
  7.  
  8. var array_of_ints = [1,3]
  9.  
  10. $("#template")
  11. .tmpl(array_of_ints)
  12. .appendTo( "#place_holder" );

猜你在找的jQuery相关文章