开发者

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() syn­tax in jQuery is enhan­ced, com­pa­red to the CSS stan­dard, so it appears that the parser puts out a war­ning since it checks for CSS com­pliance 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');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜