IE8 and jQuery selectors

前端 未结 2 1927
庸人自扰
庸人自扰 2020-12-16 01:12

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

For example, when I want to ensure th

2条回答
  •  萌比男神i
    2020-12-16 01:21

    this works for me in ie8 and ie9 first you need 2 classes with the background-color

    .even { background-color: white; } 
    .odd { background-color: #ff0; }
    

    then with jquery find tr:odd add tr:even and add the corresponding class

    $(document).ready(function () {
            $('#table1').find('tr:odd').addClass("odd"); 
            $('#table1').find('tr:even').addClass("even"); 
    });
    

提交回复
热议问题