Even and odd selectors in IE8

I am trying to highlight every second li element. It works fine with other browsers, but IE is incompatible. I tried using jQuery to solve the problem, but I have problems with its operation.

Now I have a selection of all elements in IE8 or less.

This is my code:

CSS

    .ms-quicklaunch-navmgr{
        overflow-y:scroll;
        height:650px;
    }
    .s4-ql li.static:nth-child(even){
        background:#CCC
    }
    body #s4-leftpanel{
        width:255px
    }
    .s4-ca{
        margin-left:255px
    }
    .even{
        background:#CCC
    }       

Js

$(document).ready(function(){
    $('.s4-ql li.static:even').addClass('even');
});

This is the HTML that is trying to create the style:

enter image description here

+4
source share
1 answer

Try updating jquery to

$(document).ready(function(){
    $('.s4-ql .root ul li.static:even').addClass('even');
});

your jquery targeting is currently too wide and you have 2 levels of lists

ul.root> li.static> ul.static> li

the last li is the one you need to configure, but your current jquery targets all of them

+5

All Articles