Created
April 18, 2019 09:26
-
-
Save greal/b1e08a493d225eefb6746132b8380e31 to your computer and use it in GitHub Desktop.
hasClass from jQuery on Vanilla.js
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(el, className) { | |
if (el.classList) { | |
return el.classList.contains(className); | |
} else { | |
return new RegExp('(^| )' + className + '( |$)', 'gi').test(el.className); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment