UNPKG
dom-tools
Version:
latest (0.1.4)
0.1.4
0.1.3
0.1.2
0.1.1
0.1.0
A tiny collection of DOM helpers for IE8+.
github.com/dennisduong/dom-tools
dennisduong/dom-tools
dom-tools
/
src
/
hasClass.js
13 lines
(11 loc)
•
284 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
// IE8+
//
// http://youmightnotneedjquery.com/#has_class
function
hasClass
(
el, className
) {
if
(el.
classList
) {
return
el.
classList
.
contains
(className); }
else
{
return
new
RegExp
(
'(^| )'
+ className +
'( |$)'
,
'gi'
).
test
(el.
className
); } }
module
.
exports
= hasClass;