0

For example, from from /index.html, I want to take them to another page, /list

Within /list, there is a pill nav

  • Item 1
  • Item 2
  • Item 3

Depending on what they clicked from index.html, I would like different list items active. Is there some way to do this?

Kenny Li
  • 3
  • 1
  • 1
    You would add the `active` class to the `tab` in the `pill nav` - it you add your code in a [mcve] it's easier to spot where the issue is – blurfus Jan 21 '19 at 18:26

2 Answers2

0

You first need to find which tab to activate (Maybe using fragment url, the part with "#", that you can read using some plugin like this) then activate the tabe like this :

$('get your tab').tab('show');
Victor Drouin
  • 597
  • 2
  • 15
0

Try to send number in parameter from index.html to list.html and then get that number and show tab according to that number.

add number to link in index.html like this

<a href="list.html?number=1">Item 1</a>
<a href="list.html?number=2">Item 2</a>
<a href="list.html?number=3">Item 3</a>

add this code in list.html

$(document).ready(function(){

var url_string = window.location.href; 
var url = new URL(url_string);

var number = url.searchParams.get("number");
    activeTab(number);
});

function activeTab(tab){
    $('.nav-tabs a[href="#item' + tab + '"]').tab('show');
};