标签:replace ddc false addclass ace style classname exp return
function hasClass(obj, cls) { if (obj.className) { return obj.className.match(new RegExp(‘(\\s|^)‘ + cls + ‘(\\s|$)‘)); } return false; } function addClass(obj, cls) { if (!hasClass(obj, cls)) obj.className += " " + cls; } function removeClass(obj, cls) { if (hasClass(obj, cls)) { var reg = new RegExp(‘(\\s|^)‘ + cls + ‘(\\s|$)‘); obj.className = obj.className.replace(reg, ‘ ‘); } } function removeAllClass(obj) { obj.className = ‘‘; }
标签:replace ddc false addclass ace style classname exp return
原文地址:http://www.cnblogs.com/pengchengzhong/p/6109331.html