I am simply trying to find out if the parent of the A
(i.e. the P
) has a class called some_class
defined on it. I will then use the true
/false
result in a conditional.
I have a simple structure:
<div class="things">
<p class="some_class">
<a href="something">Link One</a>
</p>
</div>
And some jQuery script:
$(function() {
$('.things a').click(function(e) {
e.preventDefault();
alert($(e.target).parent()[0].nodeName); //works, displays "P"
alert($(e.target).parent()[0].hasClass('some_class').toString()); //No output
});
});
The call to the second alert()
does nothing - no alert box is displayed at all.
What am I doing wrong?