<div class="codetitle"> <span><a style="CURSOR: pointer" data="34246" class="copybut" id="copybut34246" onclick="doCopy('code34246')"><u>复制代幣</u></a></span>代码如下:</div> <div class="codebody" id="code34246"> <br><script type="text/javascript"> <br>// 説明:追加、移除、检测 className <br>function hasClass(element, className) { <br>var reg = new RegExp('(\s|^)' className '(\s|$) '); <br>return element.className.match(reg); <br>} <br>function addClass(element, className) { <br>if (!this.hasClass(element, className)) <br>{ <br>element.className = " " className; <br>} <br>} <br>function RemoveClass(element, className) { <br>if (hasClass(element, className)) { <br>var reg = new RegExp('(\s|^)' className '(\s|$)'); <br>element.className = element.className.replace(reg,' '); <br>} <br>} <br></script> <br> </div>