Reputation: 6587
I am trying to get click event on table headers and that is easy with jQuery. I want click event to be active on all headers except first header.
I am escaping first header with :nth-child() property of CSS.
This is how i am doing-
$(function(){
$('th:nth-child(2 3 4 5)').click(function(){
$(this).CSS("font-weight","bolder");
});
});
I don't get result. Is there any better way i could do it with :nth-child()
itself?
Upvotes: 4
Views: 2073
Reputation: 27364
You can use :not
.
$('th:not(:first-child)').click(function(){
OR
You can use :gt(0)
$('th:gt(0)').click(function(){
Comment Response
For odd selector you can use :odd jQuery
selector.
Official Document
Example
$('th:not(:odd)').click(function(){
Upvotes: 9