jQuery:具有OR条件的选择器

时间:2010-10-17 09:39:52

标签: jquery jquery-selectors

我有以下代码:

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

我想抓住所有tr's thead而不是tbody。{
我怎么能这样做?

4 个答案:

答案 0 :(得分:3)

$('table.tableElements thead tr, table.tableElements tbody tr ')

有点冗长,但会奏效。

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

答案 1 :(得分:3)

尝试使用not方法排除tfoot行:

$('table.tableElements tr').not('tfoot tr').children().hover(function(){
    // code....
});

答案 2 :(得分:2)

$('table.tableElements thead tr, table.tableElements tbody tr').children().hover(function() {

});

答案 3 :(得分:1)

$('table.tableElements thead tr, table.tableElements tbody tr')