代码如下: function hasClass(obj, cls) { let reg = new RegExp("(\\s|^)" + cls + "(\\s|$)"); return obj.className.match(reg);} function addClass(obj, cls) { let Obj = obj; let objClass = obj.className; let blank = objClass !== "" ?…
function removeClass(obj, aClass) { var re = new RegExp('\\b' + aClass + '\\b'); if (obj.className != '') { if (re.test(obj.className)) { var arr = obj.className.split(' '); for (var i = 0; i < arr.length; i++) { if (arr[0] == aClass && arr[arr…
(function (window) { 'use strict'; // class helper functions from bonzo https://github.com/ded/bonzo function classReg(className) { return new RegExp("(^|\\s+)" + className + "(\\s+|$)"); } // classList support for class management //…
var utils = (function(window) { var flag = "getComputedStyle" in window; function win(attr, value) { if(typeof value !== "undefined") { document.documentElement[attr] = value; document.body[attr] = value; } return document.documentElem…