标签:style pre color ddc UNC 添加 regexp turn div
function addClass(el, className) { if (hasClass(el, className)) { return } let newClass = el.className.split(‘ ‘) newClass.push(className) el.className = newClass.join(‘ ‘) } function hasClass(el, className) { let reg = new RegExp(‘(^|\\s)‘ + className + ‘(\\s|$)‘) return reg.test(el.className) }
标签:style pre color ddc UNC 添加 regexp turn div
原文地址:https://www.cnblogs.com/ladybug7/p/12310644.html