Someuserbms
Someuserbms

Reputation: 11

How to load tabs in url using hash

Hi there fellow people of stackoverflow! I have a question how to load a tab called #A and one called #B by using http://mydomaine.com/index.html#A or #B.

It's just basic bootstrap code. I really don't know anything about jQuery so I need some help.

  <ul class="nav nav-tabs">
    <li class="active"><a href="#A" data-toggle="tab">Gutter</a></li>
    <li><a href="#B" data-toggle="tab">Jenter</a></li>
  </ul>

Upvotes: 1

Views: 151

Answers (1)

etchypap
etchypap

Reputation: 349

You could use something like this when the page loads:

$( document ).ready(function() {
  switch(window.location.hash) {
    case '#A':
      //DO WHAT YOU NEED TO DO IF A
      break;
    case '#B':
      //DO WHAT YOU NEED TO DO IF B
      break;
    default:
      //DEFAULT ACTION
  } 
});

Upvotes: 1

Related Questions