href attribute in Jquery not being pulled correctly
I am using the following code to fade in the clicked tab but it keeps fading in the same tab regardless of which list item i click on:
$('#productinfowrap .tab:first').show();
$('#subselect li').click(function() {
var thisTop = $(this).position().top;
$('#subselect li').removeClass('current');
var li = (this);
$('.pointer').animate( {'top': thisTop}, function() {
$(li).addClass('current');
});
var id = $("#subselect li a").attr('href');
$("#productinfowrap > div").fadeOut(500).hide();
$(id).fadeIn();
return false;
});
and the HTML
<ul id="subselect">
<li class=""><a href="#overview">Overview</a><span class="pointer" style="top: 225px;"></span></li>
<li class=""><a href="#applications">Applications</a></li>
<li class=""><a href="#technical">Technical</a></li>
</ul&g开发者_如何学编程t;
Other than the correct tab fading in, it all works perfectly...
Change the line to:
var id = $(this).find("a").attr('href');
Instead of $(id).fadeIn();
why not just try $(this).fadeIn();
精彩评论