Created
August 18, 2021 19:03
-
-
Save hasanmisbah/508ef30a30c604ff5f18db982399a41f to your computer and use it in GitHub Desktop.
Returns true if the element has the specified class, otherwise false .
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
// Check element have class | |
const hasClass = (el, className) => el.classList.contains(className); | |
// usage | |
hasClass(document.querySelector('p.special'), 'special'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment