简体   繁体   English

jQuery CSS选择器问题

[英]jQuery CSS selector question

Whats wrong with this CSS selector i'm using in jQuery? 我在jQuery中使用的CSS选择器有什么问题? 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. 尝试在ID表“ itable”中选择所有tr,但不选择“ mod”类,因为每个tr上可能有多个类。

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

youre using the :not selector the wrong way http://docs.jquery.com/Selectors/not#selector 您使用:not选择器使用错误的方式http://docs.jquery.com/Selectors/not#selector

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM