Reputation: 859
I am trying to get the id of the activated link of a element.
<div class="tabs">
<a class="title active" id="tab-1"></a>
<a class="title" id="tab-2"></a>
<a class="title" id="tab-3"></a>
</div>
<div id="close"></div>
<script>
$('#close').click(function() {
alert($('.tabs').find('a:active').attr('id'));
}
<\scripts>
The alert returns 'undefined'. What's not right with this?
Upvotes: 2
Views: 330
Reputation:
Please update this with your jquery
$(document).ready(function(){
$('#close').click(function() {
alert($(this).parent().find('a.active').attr('id'));
alert($('.tabs').find('a.active').attr('id'));
}
)
});
If it solve your problems accept it
Upvotes: 1