Posted in Javascript onSeptember 08, 2009
<script type="text/javascript"> // 说明:添加、移除、检测 className function hasClass(element, className) { var reg = new RegExp('(\\s|^)'+className+'(\\s|$)'); return element.className.match(reg); } function addClass(element, className) { if (!this.hasClass(element, className)) { element.className += " "+className; } } function removeClass(element, className) { if (hasClass(element, className)) { var reg = new RegExp('(\\s|^)'+className+'(\\s|$)'); element.className = element.className.replace(reg,' '); } } </script>
Javascript 检测、添加、移除样式(className)函数代码
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@