views:

30

answers:

4

I've got following code:

$('table.tableElements thead|tbody tr').children().hover(function(){
    //    How can I do this ↑
});

I'd like to catch all tr's of thead OR tbody but not tfoot.
How can I do this?

+3  A: 
$('table.tableElements thead tr, table.tableElements tbody tr ')

A bit verbose, but will work.

http://api.jquery.com/multiple-selector/

Nikita Rybak
+1 for link to documentation.
Felix Kling
+1  A: 
$('table.tableElements thead tr, table.tableElements tbody tr')
meder
+2  A: 
$('table.tableElements thead tr, table.tableElements tbody tr').children().hover(function() {

});
Marko
Upvoted because your answer is closest to OP's code.
BoltClock
@BoltClock - Yeah I saw that. 4 hours sleep in 2 days can't be good for you. The perks of working for an advertising agency. Good night gentlemen.
Marko
+2  A: 

Try the not method to exclude the tfoot rows:

$('table.tableElements tr').not('tfoot tr').children().hover(function(){
    // code....
});
Sarfraz
Not sure about performance, but I think this is worse...
Felix Kling
@Felix Kling: I am not sure about the performance either; that is what came to my mind while reading the question.
Sarfraz
Don't know why, but other suggested methods did not work for me. This works fine. Thanks.
SaltLake