<div class="codetitle"> <span><a style="CURSOR: pointer" data="44302" class="copybut" id="copybut44302" onclick="doCopy('code44302')"><u>复代码</u></a></span> 代码如下:</div> <div class="codebody" id="code44302"> <br><html> <br><머리> <br><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <br><제목></제목> <br><script type=text/javascript src="alabel.js"></script> <br><style type="text/css"> <br>.curr{배경:blue;display:inline;} <br></style> <br><br></head> <br><본문> <br><div class="clMenu"> <br><span><a href="#">1</a></span> <br></div> <br><br></body> <br></html> <br> </div> <br>재alabel.js中: <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="36016" class="copybut" id="copybut36016" onclick="doCopy('code36016')"><u>复主代码</u></a></span> 代码如下:</div> <div class="codebody" id="code36016"> <br>window.onload = function () <br>{ <br>var aspan = document.getElementsByTagName("span"); <br>var i = 0; <br>for (i = 0; i { <br>aspan[i].onclick = function () <br>{ <br>for (i = 0; i < ; asspan.length; i) asspan[i].className = ""; <br>this.className = "현재"; <br>}; <br>} <br>}; <br> </div> <br> 这样就可以实现에서 标签적 时候给其添加红红color的背景. <br><br>注意: currative属性中display不能是block,否则添加的背景是一整行。