JSFiddle - React, Tailwind, and code Playground

by J. Albert Bowden

HTML

<div id="test" class="class1 class5"></div>

JavaScript

function hasClass(element, cls) {
    return (' ' + element.className + ' ').indexOf(' ' + cls + ' ') > -1;
}

var el = document.getElementById('test');

alert(hasClass(el, 'class1'));
alert(hasClass(el, 'class'));