摘要: 刚开始这么写的:1 function hasClass(element, cls) {2 var regexp = new RegExp("\\b" + cls + "\\b");3 return element.className.search(regexp) !== -1;4 } // end hasClass()用\b匹配word boundary,这样可以有效处理"aaa", "aaa bbb"的匹配,但是忘记了word boundary的明确定义Before the first character in 阅读全文
posted @ 2013-12-13 07:36 我的百科全书 阅读(1208) 评论(0) 推荐(0) 编辑