0

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? :)

Edited by diafol: Not php - wrong forum

2
Contributors
2
Replies
14
Views
4 Years
Discussion Span
Last Post by mmcdonald
0

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>

Edited by JorgeM

0

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?

Edited by mmcdonald

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.