增加Jquery的第n个子选择器
参考那个
我需要遍历第n个子选择器,就是这样
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推送到arrays以供进一步使用。
任何forms的帮助都将是值得赞赏的。
问候
您无法访问'td:nth-child(i+1)'
类的变量。
将其更改为:
var tmp = $(this).find('td:nth-child('+(i+1)+')');