首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >jTemplates中的局部变量/for循环

jTemplates中的局部变量/for循环
EN

Stack Overflow用户
提问于 2012-04-24 01:25:32
回答 1查看 2K关注 0票数 1

是否可以在jtemplate中创建局部变量或for循环(而不是foreach)?我想给HTML元素提供唯一的id,并且需要一个计数器之类的东西。谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-04-24 01:33:47

使用$index

代码语言:javascript
复制
$index - index of the element in the table
$iteration - ID of the iteration (the next number begins from 0)
$first - is this the first iteration?
$last - is this the last iteration?
$total - the total number of iterations

例如

代码语言:javascript
复制
{#foreach $T.Rows as row}
  $T.row$index
{#/for}

阅读http://www.codeproject.com/Articles/45759/jQuery-jTemplates-Grid

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10285236

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档