Menu

Go to Specific Tab on Page Reload or Hyperlink in Bootstrap Using Jquery

PHP By Jul 31, 2015 No Comments

Clicking on tab and than on reload we will go to the specific tab always. If we talk about the twitter bootstrap than we will go to the active tab. We search a lot and found this we are putting it here as it will help you also. From many days we were facing this issue with my application and at last we got some help and discovered the script to solve this issue.

We assume that if you are searching for this you already inserted the tabs in your page. So we will just put the query.

 

var url = document.location.toString();
if (url.match('#')) {
    $('.nav-tabs a[href=#'+url.split('#')[1]+']').tab('show');
    window.scrollTo(0, 0);
} 

// Change hash for page-reload
$('.nav-tabs a').on('shown.bs.tab', function (e) {
    window.location.hash = e.target.hash;
    window.scrollTo(0, 0);
});

It will create your tab open at reload. Thank you hope you like it if you have any issues than please let us know.

Author

Hello i am Vivek Moyal PHP developer and writes tutorials for students and beginners. Love to explore new cities

No Comments

Leave a comment

Your email address will not be published. Required fields are marked *