Hey all,

I'm trying to make a link outside of the nav-tabs class, specifically in a paragraph, that changes to another tab on the same page.

Granted that I know this requires JS and that I know nothing of JS (Another book i ordered this morning :) ) here is what I've tried (with partial success):

My link: <a class='tab-switch' href='#tab_1_3' data-toggle='tab'>biography</a>

My JS:

        $('.tab-switch a').on('click', function (e) {
            e.preventDefault();
            $(this).tab('show');
        });

    });

What currently happens:
When the link is clicked the CONTENT of the tab changes (woop!) but the tab NAV <li> doesn't change. So I'm seeing the right content but the actual tab at the top doesn't change.

Which oracle will save me this time? :)

Recommended Answers

All 2 Replies

I beleive the selector is incorrect in your example. If you are trying to select those elements with a class of "tab-switch", it should be...

$('.tab-switch')

This selector $('.tab-switch a') will locate elements with a class of 'tab-switch', that have a "child" element of type anchor <a/>.

For example...

<div class="tab-switch">
  <a href="#">link</a>
</div>

Thank you @JorgeM, I've made the change but the problem still occurs. I must say that I added that JS script by myself so it may not be required. I might be looking at this in the wrong way entirley. Does anyone know a method of hyperlinking to another tab outside of a nav class?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.