robjmills
robjmills

Reputation: 18598

jQuery CSS selector question

Whats wrong with this CSS selector i'm using in jQuery? Trying to select all tr's within a table of ID "itable" without a class of "mod" where its possible for multiple classes to be on each tr.

if($('#itable tr:not[class~=mod]').length == 0){
    //something
}

Upvotes: 1

Views: 255

Answers (3)

Flatlin3
Flatlin3

Reputation: 1659

youre using the :not selector the wrong way http://docs.jquery.com/Selectors/not#selector

if($('#itable > tr:not(.mod)').length == 0){
    //something
}

Upvotes: 1

eozzy
eozzy

Reputation: 68790

if($('#itable tr:not(.mod)')[0]){
    //something
}

Upvotes: 4

Quentin
Quentin

Reputation: 944524

#itable tr:not(.mod)

Upvotes: 1

Related Questions