how to get the href attr of a parent element with jquery?
how to get the href attr of a parent element with jquery?
HTML
<div class="auditions_date">
<div class="new_green above_deadline">
<a href="/auditions/2 ?>">Contact</a></div>
<span class="aud_recommend"><a class="222" id="aud_recommend" href="#recommend_data">
test</a></span>
</div>
<div class="auditions_date">
<div class="new_green above_deadline">
<a href="/auditions/3 ?>">Contact</a></div>
<span class="aud_recommend"><a class="333" id="aud_recommend" href="#recommend_data">
test</a></span>
</div>
JavaScript
$(document).ready(function () {
$('a#aud_recommend').on("click", function (e) {
//e.preventDefault();
console.log($(this).html());
var j = $(this).parents('.auditions_date').find('.new_green a').attr('href');
alert(j);
//console.log(j);
});
});