views:

124

answers:

2

Hello,

my question is how I can change the selector so that it wil exclude the second column off the hover event

I did try some other variations like nth-child, but no luck yet. Could there be something wrong with the syntax maybe??

$('.row_class td:not(:eq(1))').hover(

thanks, Richard

A: 

$('.row_class td:first-child').hover(

Ballsacian1
this one only hovers the first cell in the row, I think
This should work just fine. Especially with the class specified. If that class is on every row and he wants only the first column of that row to have the hover, then this should work great.
Ballsacian1
He never said he wanted the first column, he said he _didnt_ want the _second_ column. Presumably he has 3 columns or more and he wants to exclude just the 2nd one. Your example only includes the first one.
Paolo Bergantino
+2  A: 

Try this:

$('tr.row_class td:not(:nth-child(2))').hover(function() {
    $(this).css('color','red');
}, function() {
    $(this).css('color','black');
});

It works for me.

By the way, class selectors are slow. If you know .row_class will only be applied to <tr> elements, you should make the selector be tr.row_class like in my example. Just a free tip. :)

Paolo Bergantino
thanks, I understand, I will try this one
$('tr.row_class td:not(:nth-child(2))').hover(it only selects the first column, and the hover is still attached to the second column
In the link I put up that is obviously not happening... Try putting your mouse over "Test" and "yay" and they will turn Red. If you put your mouse over "Not" it will stay black. You're doing something else wrong. Do you have the selector wrapped in document.ready?
Paolo Bergantino
I am sorry, I think you are rightI have to change something else, so that it will not respond anymoreto a certain event. Thanks for your input
I mean, you are right!