Skip to content
Advertisement

Keep active tab on page refresh in bootstrap 4 using local storage?

I am trying to keep selected tab active on page refresh. but when i am not able to find any solution for tabs in bootstrap 4. i tried to make changes according to bootstrap 3 solutions but nothing work. please help me.

HTML

JavaScript

this is js i am using but it dosen’t work.

JS

JavaScript

Advertisement

Answer

The jQuery selector is wrong: $('#myTab a[href="' + activeTab + '"]'), it should be…

$('.nav-tabs a[href="' + activeTab + '"]').tab('show');

https://www.codeply.com/go/C2B3mcrgSJ

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement