Created
January 28, 2014 07:57
-
-
Save pascalmaddin/8663741 to your computer and use it in GitHub Desktop.
Here is a little snippet if you're trying to check wether element contains a class, without using jQuery.
From http://sonnyt.com/javascript-check-if-element-has-class/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function hasClass(element, className) { | |
return element.className && new RegExp("(^|\\s)" + className + "(\\s|$)").test(element.className); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment