Santosh
Santosh

Reputation: 99

Why jquery last-child not working in ie7 and 8

I want to run :last-child in ie 7. I know its not possible with only css but i added jquery Heres the following code in js

$('#columncontainer > div:nth-child(even)').addClass("mar-right");

and my html is

 <div id="columncontainer"> <div class="list-type"></div> <div class="list-type"></div> </div>

is there anything missing with ie7 and ie8 else this code is working every where in browser.

Upvotes: 1

Views: 948

Answers (3)

YogeshWaran
YogeshWaran

Reputation: 2281

i tried your code and script .it works fine for me in ie7 and ie8 please refer the link.

http://jsfiddle.net/Ta9xu/1/

Upvotes: 0

Eli
Eli

Reputation: 14827

:last-child doesn't work in IE7, try this instead:

$('#columncontainer').last().addClass('mar-right'); 

Upvotes: 1

Alessandro Minoccheri
Alessandro Minoccheri

Reputation: 35973

IE7 doesn't support nth-child See this link to view all browser compatibility

BROWSER COMPATIBILITY

to solve this problem you can add a class with jquery and select it into your css file like this:

$('#columncontainer:nth-child(even)').addClass('mar-right');

Upvotes: 0

Related Questions