日期:2014-05-16 浏览次数:20302 次
<script type="text/javascript"> 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>