Johny D Good
Johny D Good

Reputation: 427

using jquery, accessing parent div and checking if it has a specific class

How would I access parent div and check if it has a specific class

<div class="current">
    <img src="aaa.jpg" class="me-child">
</div>

with jquery clicking on the div and using this keyword, I want to know if parent div has the class of current

thanks

Upvotes: 0

Views: 50

Answers (1)

MoeZir
MoeZir

Reputation: 31

if($(this).parent().hasClass("current")) return true;

Upvotes: 1

Related Questions