tags:

views:

160

answers:

2

I've noticed that Firefox throws me a warning on the following jQuery code:

$("li.example div.code:gt(4)").hide();

CSS Error: Unknown pseudo-class or pseudo-element 'gt'.

According to jQuery, it all should be correct. And it works, but I wonder how to fix this error for cleanness sake.

A: 

Actually it will work by class reference, I don't see a reason why your code wouldn't work, could you post your div code because it seems to work fine for me, but Im using IE

$("li.example td.code:gt(4)").hide();

the above code will work because it will look for the 4th div and hide all the divs after that one, remembering that the index starts a 0

Demo

TStamper
thanks! My code works, it's just Firefox gives CSS error (as a warning). It's a shame it is not considered a correct way when it performs as required.
kimka
I just found that your example gives the same CSS Error. It must be something different!
kimka
my example gives an error in firefox,? if so can you post your div code that you're trying it on?
TStamper
Hi TStamper, yes - your example, *on your* webpage gives the same error!
kimka
@kimka- did you try to run my actual demo in your browser, or just the line I put up?
TStamper
A: 

Firefox will throw this warning (not error!) because it attempts the CSS selector which it doesn't think is valid. That's ok though, you can ignore this warning, you know it works, just ignore the console error in this instance. It'll do this for any selector it doesn't recognize.

You can read the jQuery nabble discussion on the same topic here.

Nick Craver