开发者

Associate an element placed out of tab with tab items

I have a tab script that works:

http://jsfiddle.net/fmqeh/8/

With click on ".开发者_开发技巧tab" items, ul.tab li items has class "actives". But with click on

<a class="bdn" href="#tab2">Go to Tab 2</a>

<a class="bdn"> couldnt add class="actives to tab items. How can I do this with scroll to

<div class="tab_content chart" id="tab2">
    this is the content of tab2
</div>

Thanks in advance


It's a lot easier if you just trigger the click event on the tab you want to activate:

$(".bdn").click(function(e) {
    var $tabs = $('ul.tab');
    $tabs.find('a[href="#tab2"]').click();
    $(window).scrollTop($tabs.offset().top);
    e.preventDefault();
});

Your fixed demo: http://jsfiddle.net/fmqeh/11/


I think your selector should be:

 $("ul.tab li:nth-child(2)").addClass("actives");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜