jQuery check if has class

with .hasClass():

<script>
if ($('.target').hasClass('selected')) { // no dot in classname
// .target elem has the class .selected
}
</script>

with .is():

<script>
if ($('.target').is('.selected')) {
// .target elem has the class .selected
}
</script>

Leave a Reply

Your email address will not be published. Required fields are marked *