Issue
How would I output to console the value of the parent div's class? My current code outputs the entire HTML line
i.e if I have this
<div class="hello">
<a id="foo"></a>
</div>
$(document).on('click', 'a', function(e) {
console.log($(this).parent("div"));
}
Why do I keep getting this in my console?
<div class="hello">
The only thing I want console to show is "hello" (without the quotations).
Solution
Use .attr()
console.log($(this).parent("div").attr("class"));
Answered By - kost
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.