check if the element has the specified class

PHOTO EMBED

Sat Feb 26 2022 02:14:33 GMT+0000 (Coordinated Universal Time)

Saved by @mboljar

const hasClass = (el, className) => el.classList.contains(className);

// Example
hasClass(document.querySelector('p.special'), 'special'); // true
content_copyCOPY

https://madza.hashnode.dev/24-modern-es6-code-snippets-to-solve-practical-js-problems?guid