开发者

jQuery excluding certain columns from selection

I have a table where each row is clickable. Some columns in this table have links in them. I'd like to exclude 'link' columns from jQuery selection.

My first col开发者_如何学编程umn, and third column contains links, so I'm doing the following after iterating through each row in the table:

row.children('td:gt(2)') // for column 3+
row.children('td:lt(2)') // for columns 0 and 1

Is there any way to join these two lines?


row.children('td:gt(2), td:lt(2)')

edit: ah, artlung beat me to it.


You could also use the :not with :eq selector...

row.find('td:not(:eq(2))')

or :not with the :nth-child selector

row.children('td:not(:nth-child(3))')

*NOTE: :eq index starts with zero while the :nth-child selector starts with one.

I was going to use children for the :eq selector example, but it only worked on the first row.


This works:

row.children('td:gt(2),td:lt(2)')
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜