开发者

CSS Error when using jQuery's gt() selector?

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开发者_JAVA技巧 wonder how to fix this error for cleanness sake.


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


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜