<div class="htmlarea"> <textarea id="runcode23025"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="keywords" content="PRcss,xhtml,html,css,js,book,个人主页,无聊,神经,懒惰"> <meta name="description" content="PRcss的个人主页,无聊的,神经的,懒惰的..."> <meta name="Author" content="PRcss,qq:50198763"> <meta name="Copyright" content="本页版权归PRcss所有。All Rights Reserved"> <title>2줄씩 걸러 색상 변경 - www.jb51.net</title> <style type="text/css"><!-- .t1 {background:#fff;} .t2 {background:#eee;} .up {background:#e5e5e5;} div {float:left;width:45%;} ul {padding:30px 0 0;margin:0;} --></style> <div id="a"> <ul> <li> </li>1<li> </li>2<li> </li>3<li> </li>4<li> </li>5<li> </li>6<li> </li>7</ul> <ul> <li> </li>1<li> </li>2<li> </li>3<li> </li>4<li> </li>5<li> </li>6<li> </li>7</ul> <ul> <li> </li>1<li> </li>2<li> </li>3<li> </li>4<li> </li>5<li> </li>6<li> </li>7</ul> </div> <div id="b"> <ul> <li> </li> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> <li>6</li> </ul>7<ul> <li> </li> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> <li>6</li> </ul>7<ul> <li> </li> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> <li>6</li> </ul>7</div> </textarea> <br> <input onclick="runEx('runcode23025')" type="button" value="运行代码"> <input onclick="doCopy('runcode23025')" type="button" value="复制代码"><input onclick="doSave(runcode23025)" type="button" value="保存代码"><a href="http://www.jb51.net/article/23421.htm" title="查看具体详情" target="_blank"> </a> </div>[Ctrl A 모두 선택 참고: <script type="text/javascript"><!-- // 返回Id、Tag function Pid(id,tag){ if(!tag){return document.getElementById(id);} else{return document.getElementById(id).getElementsByTagName(tag);} } function ghhs(id,box,tag,s){ if(box==""){//alert("指定当前容器中所有标记"); var line=Pid(id,tag); ghhs_(line,s); } else{//alert("分别指定各子容器中的标记"); var lines=Pid(id,box);//得到子容器的数量 for(var i=0;i<lines.length;i++){//得到各子容器的tag ghhs_(lines[i].getElementsByTagName(tag),s); } } } function ghhs_(line,s) { for (var i=1;i<line.length+1;i++) { line[i-1].className=(i%2>0)?"t1":"t2"; } if(s=="no"){ return; } else if(!s){ for(var i=0;i<line.length;i++) { line[i].onmouseover=function(){ this.tmpClass=this.className; this.className+=" up"; } line[i].onmouseout=function(){ this.className=this.tmpClass; } } } else{ for(var i=0;i<line.length;i++) { line[i].tmep=i; line[i][s]=function(){ ghhs_tab(this.tmep); } } } function ghhs_tab(s){ for(var i=0;i<line.length;i++){ if(!line[i].tmpClass){ line[i].tmpClass=line[i].className+=" pr1984_com"; } if(s==i){ line[i].className+=" up"; } else { line[i].className=line[i].tmpClass; } } } } //--></script>외부 J를 도입해야 하는 경우 실행하려면 새로 고쳐야 합니다 <script type="text/javascript"><!-- ghhs("a","ul","li") //--></script>]<script type="text/javascript"><!-- ghhs("b","","li") //--></script>