get class by indexOf

PHOTO EMBED

Tue Jul 23 2024 06:10:31 GMT+0000 (Coordinated Universal Time)

Saved by @davidmchale #function #indexof #classname

 function getClass(element, className) {
    return element.className.indexOf(className) !== -1;
  }

// returns boolean

//alterntively use

function hasClass(element, className) {
    return element.classList.contains(className);
}
content_copyCOPY