Home > Web Front-end > JS Tutorial > body text

Solution to table interlaced color change in IE8 chrome_javascript skills

WBOY
Release: 2016-05-16 18:23:32
Original
1066 people have browsed it

For version codes above IE8, only CSS is required
tr{ background-color:expression('#F8F8F8,#EFEFEF'.split(',')[rowIndex%2]); }
For below IE8 The version code requires CSS and JS to be completed together:
First define two CSSs, the code is as follows:

Copy code The code is as follows:

.tr1{background-color:#fff;}
.tr2{background-color:#00ff;}

Actually write JS Code, the code is as follows:
Copy code The code is as follows:

onload=function(){
var trs=document.getElementById("tbid").getElementsByTagName("tr");//Get all tr ​​information in the table of tbid
for(var i=0;i{
 if(i%2==0)
trs[i].className="tr1";
else
trs[i].className="tr2";
}
}

Author: chenhuzi
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template