Change active tab when the user clicks in a specific link in another page
I have this link "
http://proj.test/congress/1/congress-test/registration " where the user has a form to register in a congress. Its a muli step form, in the step 2 there is a message informing the user that he was registered with success.In this message there is a link "My Tickets":
- <a href="user/profile">My Tickes</a>
When the user click in "My Tickets" he goes to " "proj.test/user/profile?user=1" that is the page to edit some user account settings. In this page there are some tabs like "General Info", "My Tickets".
The default tab is "General Info", that is the tab to update some user general info.
Do you know how to achieve that?
The links to the tabs "General info" and to the tab "My Tickets" in the uer account page (proj.test/user/profile?user=1) have this hrefs below:
- <ul class="nav nav-pills bg-light-gray account_options" role="tablist">
- <li class="">
- <a class="nav-link active" href="#generalInfo" data-toggle="tab" role="tab">
- <i class="fa fa-user" aria-hidden="true"></i> <span class="d-none d-lg-inline-block">General Info</span></a>
- </li>
- <li class="disabled">
- <a class="nav-link" href="#myTickets" data-toggle="tab" role="tab">>MyTickets</span></a>
- </li>
- ...
- </ul>
Then the tabs are like below:
- <div class="tab-content bg-white" id="myTabContent">
- <div class="tab-pane fade show active clearfix" id="generalInfo" role="tabpanel" aria-labelledby="home-tab">
- <form method="post" action="" class="clearfix">
- ...
- </form>
- </div>
-
- <div class="tab-pane clearfix fade" id="myTickets" role="tabpanel" aria-labelledby="contact-tab">
- ...
- </div>
- </div>
I was trying with jQuery like:
- var path = window.location.href;
- alert(path);
- $('.account_options a').each(function () {
- if (this.href === path) {
- $('a[href="#' + path + '"]').addClass('active');
- }
- });
But its not working.
The "My Tickets" dont become active when the user clicks in the link " `<a href="/user/profile"My Tickes</a>`" in the registration page.