jQuery check if has class

with .hasClass():

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

with .is():

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

Leave a Reply

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