☰
👋 Hello! I'm Alphonsio the robot. Ask me a question, I'll try to answer.
In jQuery, how to check if an element has a given class?

The jQuery .hasClass() method checks if at least one of the selected elements have a given class name:

<div id="myId" class="selected"></div>

// true
$('#myId').hasClass('selected')

// false
$('#myId').hasClass('non-existing')

More