👋 Hello! I'm Alphonsio the robot. Ask me a question, I'll try to answer.
With jQuery, how do I test whether an element has a particular 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>
$('#myId').hasClass('selected')
$('#myId').hasClass('non-existing')