jQuery selector syntax gives Firefox warning
The following code
stringref = "tab_2";
jQuery('.someclass a:not(.someclass #a_someclass_'+st开发者_StackOverflow社区ringref+')').css('color', '#000');
gives me this warning in the FF 3.5.5 error console and I can't figure out why:
Warning: Missing closing ')' in negation pseudo-class '#a_someclass_tab_2'.
Is my syntax failing me or has FF gone bonkers ?
I think your selector is too complex -- I don't think spaces are allowed within a :not()
pseudoclass. Are you trying to match a
descendants of .someclass
that do not have the given ID? If so, just remove the .someclass
within the :not()
.
Firefox (3.5.6) indeed does throw a Warning (if you are not seeing it in Firebug, it's because you do not have 'Show CSS Errors' enabled - see Firebug Console tab).
Firefox is, in a false positive way, parsing the jQuery selector syntax as non-compliant CSS. It is safe to ignore this FF warning (it's not an error remember).
I second Dave in that it is most likely the space in your selector.
The :not() syntax in jQuery is enhanced, compared to the CSS standard, so it appears that the parser puts out a warning since it checks for CSS compliance only.
The syntax looks to be fine, and didn't give me any errors. But I would simplify it a bit, which should help you avoid mis-fired warnings.
var stringref = "tab_2";
jQuery('a.someclass:not(#a_someclass_'+stringref+')').css('color', '#000');
精彩评论