jQuery模板可以绑定到原始数​​组吗 [英] Can jQuery template bind to a raw array

查看:61
本文介绍了jQuery模板可以绑定到原始数​​组吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给予

<div id="place_holder" />

<script id="template" type="text/x-jquery-tmpl">
WHAT DO I PUT HERE
</script>

var array_of_ints = [1,2,3]

$( "#template" )
        .tmpl( array_of_ints   )
        .appendTo( "#place_holder" );

我可以在模板中放入哪些内容?

What can I put within the template to get ?

<ul>
  <li>1</li>
  <li>2</li>
  <li>3</li>
</ul>

推荐答案

<ul id="place_holder">
</ul>

<script id="template" type="text/x-jquery-tmpl">
    <li>${}</li>       
</script>

var array_of_ints = [1,2,3]

$("#template")
    .tmpl(array_of_ints)
    .appendTo( "#place_holder" );

这篇关于jQuery模板可以绑定到原始数​​组吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆