Jagadeesh
Jagadeesh

Reputation: 121

last-child is not working in IE8 browser

CSS : last-child is not working in IE8 browser any alternate solution for this tag.

I tried with :last-of-type, but also it is not working.

Can any one help me on this ?

Thanks Jagadeesh.N

Upvotes: 0

Views: 295

Answers (3)

NickHTTPS
NickHTTPS

Reputation: 799

You can always load a polyfill for that:

<!--[if (gte IE 6)&(lte IE 8)]>
  <script type="text/javascript" src="selectivizr.js"></script>
<![endif]-->

Here's the link: http://selectivizr.com/

Upvotes: 0

Bhojendra Rauniyar
Bhojendra Rauniyar

Reputation: 85545

:first-child is only supported in IE8 but sorry to say that :last-child isn't supported for IE8.

To be easy just define the class name for that div and apply the css


Solution with jQuery:

$('*').last().addClass('last-child');

Or,

$('*:last-child').addClass('last-child');/*use it with care*/

So now you can simply use div.last-child as a selector in your stylesheet.

Upvotes: 1

Karmacoma
Karmacoma

Reputation: 668

IE8 does not support :last-child So, you can use this method:

Your best bet is to explicitly add a last-child (or similar) class to that item, and apply li.last-child instead.

Upvotes: 0

Related Questions