Reputation: 28336
How do I get the name of the class in the parent ? I have "test stuff" and therefore can get it's parent. Once I have the parent. how do I get the class property?
<div class="ABC">test stuff</div>
$(this).parent()
- gets the DIV with class ABC
Upvotes: 1
Views: 111
Reputation: 24506
$(this).parent().attr('class')
is a way to do it. If the element could potentially have more than one class, you might find the .hasClass() method better.
Upvotes: 1
Reputation: 23303
$(this).parent()[0].className;
$(this).parent().attr("class");
Also check out the other class manipulation functions.
Upvotes: 0