This article describes the method of JS+CSS to implement the interlaced color change effect of Li list. Share it for your reference. The specific implementation method is as follows:
Copy the code as follows:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>CSS+Js realizes the interlaced color change effect of Li list</title>
</head><body>
<style>
.mytable {border-collapse:collapse;border:solid #6AA70B;border-width:0px 0 0 0px;width:50%;}
.mytable ul li {padding-top:5px;text-indent:2em;list-style:none;background:url(/images/20110704/new_dot.gif) 3px 50% no-repeat;border-bottom:#6AA70B 1px dotted ;font-family: "Verdana,安体";font-size: 12px;color:#008000;text-align:left;height:25px;}
.mytable ul li.t1 {background-color:#EFFEDD;}
.mytable ul li.t2{background-color:#ffffff;}
.mytable ul li.t3 {background-color:#D2FCA0;}
</style>
<body style=margin:0;><br><br><br>
<div align="center">
<div class=mytable id=tab>
<ul>
<li>
<a target="_blank" href="//www.VeVB.COM/article/61182.htm">
Methods to implement text and picture drag and drop effects in JavaScript</a></li>
<li>
<a target="_blank" href="//www.VeVB.COM/article/61181.htm">
jQuery method to realize the display effect of clicking on pictures and turning pages</a></li>
<li>
<a target="_blank" href="//www.VeVB.COM/article/61180.htm">
PHP method to implement recursion and infinite classification</a></li>
<li>
<a target="_blank" href="//www.VeVB.COM/article/61179.htm">
PHP method to double the value (number) of each unit in a multi-dimensional array</a></li>
<li>
<a target="_blank" href="//www.VeVB.COM/article/61178.htm">
Analysis of common functions examples of adding and deleting units in php arrays</a></li>
<li>
<a target="_blank" href="//www.VeVB.COM/article/61177.htm">
JS+CSS implements draggable pop-up prompt box</a></li>
<li>
<a target="_blank" href="//www.VeVB.COM/article/61176.htm">
js implements the method of selecting the picture to be displayed on the drop-down box</a></li>
<li>
<a target="_blank" href="//www.VeVB.COM/article/61175.htm">
js to realize how to click on the image to copy the image address to the paste board</a></li>
</ul></div><script type="text/javascript">
<!--
var Ptr=document.getElementById("tab").getElementsByTagName("li");
function $() {
for (i=1;i<Ptr.length+1;i++) {
Ptr[i-1].className = (i%2>0)?"t1":"t2";
}
}
window.onload=$;
for(var i=0;i<Ptr.length;i++) {
Ptr[i].onmouseover=function(){
this.tmpClass=this.className;
this.className = "t3";
};
Ptr[i].onmouseout=function(){
this.className=this.tmpClass;
};
}
//-->
</script>
</body>
</html>
I hope this article will be helpful to everyone's JavaScript programming.