增加Jquery的第n个子选择器 [英] Increment nth-child Selector of Jquery

查看:118
本文介绍了增加Jquery的第n个子选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

参考

我需要遍历nth-child选择器,这是

I need to iterate through nth-child selector, That is

var i =1;    
var tmp = $(this).find('td:nth-child(i+1)'); // Wondering How this behavior can be achieved     
i++;

我有一个行/行在一个网格中动态生成的列,我想循环每个网格单元和存储具有报头的网格单元的值,即其ID。
我想知道如果我可以增加选择器在nth-child所以。每次迭代它捕获下一个gridcell值。因此,我可以把它的值和Id数组进一步使用。

What i have is a row/rows with dynamically generated columns in a grid, i want to loop through each grid cell and Store value of each grid cell with header i.e its ID. i was wondering if i could increment selector in nth-child so .each for every iteration it catches the next gridcell value. And so I can push its value and Id to array for further use.

任何类型的帮助将是感激的。

Any sort of help would be appreciative.

推荐答案

您不能访问变量'td:nth-​​child 1)'

更改为:

var tmp = $(this).find('td:nth-​​child('+(i + 1)+')');

这篇关于增加Jquery的第n个子选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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