Andy
Andy

Reputation: 3021

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>

Other than the correct tab fading in, it all works perfectly...

Upvotes: 0

Views: 65

Answers (2)

Shadow Wizard
Shadow Wizard

Reputation: 66389

Change the line to:

var id = $(this).find("a").attr('href');

Upvotes: 1

duncan
duncan

Reputation: 31912

Instead of $(id).fadeIn(); why not just try $(this).fadeIn();

Upvotes: 0

Related Questions