<div class="htmlarea"> <textarea id="runcode72169"> <title> New Document </title> <meta name="Generator" content="EditPlus"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> <style type="text/css"> <!-- .li01 { background:#FFF; } .li02 { background:#eeeeee; } --> </style> <div><ul id="list01"> <li class="title"><a href="#">title</a></li> <li><a href="#">111</a></li> <li><a href="#">222</a></li> <li><a href="#">333</a></li> <li><a href="#">444</a></li> <li><a href="#">555</a></li> <li><a href="#">666</a></li> </ul></div> <script language="Javascript"> objName=document.getElementById("list01").getElementsByTagName("li") for (i=0;i<objName.length;i++) { (i%2==0)?(objName(i).className = "li01"):(objName(i).className = "li02"); } </script> </textarea><br><input onclick="runEx('runcode72169')" type="button" value="运行代码"> <input onclick="doCopy('runcode72169')" type="button" value="复制代码"> <input onclick="doSave(runcode72169)" type="button" value="保存代码">[Ctrl+A 全选 注:<a href="http://www.jb51.net/article/23421.htm" title="查看具体详情" target="_blank">如需引入外部Js需刷新才能执行</a>]</div> <br>