css - IE8 and jQuery selectors -


Today it came to my attention that the combination of jQuery selectors and addClass () functions does not work properly on IE8.

For example, when I want to make sure that even the numbered rows are selected in the table, I wrote:

  jquery (document) .ready ( Function ($) {AddClass ("even")}}  

and for CSS, I have written:

 $ ("# Table 1 Tr: nth-child (also) ")  # table1 tr: nth-child (even), # table1 tr.even {background-color: # ff0;}  

Firefox , Pseudo-class selector in cos file, even in Chrome, Safari and Opera, even number of lines However, in IE8, this is not the case.The rows have no different background color.

This is strange because when I used:

 < Code> jQuery (document) .ready (function ($) {$ ("# table1 tr: nth-child (even)"). Css ({"background-color": "# Ff0"}}} }  

The selected rows are highlighted in IE8.


An example of the problem can be seen here - Firefox, Chrome, Safari and Opera In, weird rows have a "strange" "The class is assigned. However, in IE8, they have not been assigned the "weird" category and are not highlighted.

The selector works correctly on the jQuery side ... but the IE8 style rule is completely Rejects (in compliance) because it is nth-child :

  T: Nth-child (funny) TD, tr.odd td {background-color : # 86B486; }  

If you divide it, then it will work correctly:

  tr: nth-child (strange) td {background-color} : # 86B486; } Tr.odd td {background-color: # 86B486; }  

(A rule removes IE8) and, with rule division.


For perfection, leave the rule behind not help:

  tr.odd td, tr: nth-child (strange ) Td {background-color: # 86B486; }  

Comments