Saurav Jamwal
Saurav Jamwal

Reputation: 374

How to give a link for bootstrap-tabs from another page

I want to give a link for nav-tabs from another page. I mean to say that, I want to access nav-tabs from another page. I will give you the detailed information about it.

On my website there are two pages one is index.html page and another is a business-listing.html. In business-listing page I used nav-tabs. And I want to access these tabs from index.html page.

Give some idea how to give a link.

The code is too long, so I can't put it here.

I'm trying this code to give a link <a href="business-listing.html#tab-id">Link to Tab1</a>, but it can't work.

Upvotes: 0

Views: 3708

Answers (1)

JensV
JensV

Reputation: 4544

You'd need to write some JavaScript code to make this work. The tab switching occurs when you click on a navbar link. Something like:

$(function () {

    var tabId = window.location.hash;

    $("#yourTabUl").find('a[href=' + tabId + ']').tab('show');

});

Replace yourTabUl with the ìd of your ul-element of the TabLinks. (Create an id if needed)

Also see the documentation here: https://getbootstrap.com/javascript/#tabs

Upvotes: 2

Related Questions