UNPKG

@ssports_fe/ssutils

Version:
11 lines (10 loc) 345 B
const hasClass = (el, cls) => { if (!el || !cls) return false; if (cls.indexOf(' ') !== -1) throw new Error('className should not contain space.'); if (el.classList) { return el.classList.contains(cls); } else { return (' ' + el.className + ' ').indexOf(' ' + cls + ' ') > -1; } }; module.exports = hasClass;