Specify multiple columns with nth-child()
I'm using nth-child开发者_高级运维 in my jquery selector to identify columns to modify. I have 5 columns (1-5) and I want to modify only 2,3, and 4. Is there a way to do this with nth-child? Something like:
$('#example tbody tr td:nth-child(2||3||4)')
I have tried several combinations but nothing seems to work. Im pretty new to jQuery selectors any help you could throw at me would be greatly appreciated.
Regards, Joe Chin
You could use .nextUntil()
like this:
$('#example tbody tr td:nth-child(1)').nextUntil(':nth-child(5)');
$('#example tbody tr td:not(:last-child, :first-child)')
I would use slice, it is more dynamic.
$('#example tbody tr td').slice(1,4)
Heres the API for the slice method.
精彩评论