Change active tab when the user clicks in a specific link in another page

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":


  1.      <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.

 My doubt is how to turn the "My Tickets" tab active when the user in the congress registration page ( http://proj.test/congress/1/congress-test/registration ) clicks in "My Tickets".


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: 

  1.     <ul class="nav nav-pills bg-light-gray account_options" role="tablist">
  2.      <li class="">
  3.         <a class="nav-link active" href="#generalInfo" data-toggle="tab" role="tab">
  4.             <i class="fa fa-user" aria-hidden="true"></i> <span class="d-none d-lg-inline-block">General Info</span></a>
  5.     </li>
  6.     <li class="disabled">
  7.         <a class="nav-link" href="#myTickets" data-toggle="tab" role="tab">>MyTickets</span></a>
  8.     </li>
  9.     ...
  10.     </ul>

Then the tabs are like below:

  1.     <div class="tab-content  bg-white" id="myTabContent">
  2.      <div class="tab-pane fade show active clearfix" id="generalInfo" role="tabpanel" aria-labelledby="home-tab">
  3.      <form method="post" action="" class="clearfix">
  4.             ...
  5.             </form>
  6.         </div>
  7.     
  8.         <div class="tab-pane clearfix fade" id="myTickets" role="tabpanel" aria-labelledby="contact-tab">
  9.         ...
  10.         </div>
  11.     </div>

I was trying with jQuery like:

  1.     var path = window.location.href;
  2.         alert(path);
  3.         $('.account_options a').each(function () {
  4.             if (this.href === path) {
  5.                 $('a[href="#' + path + '"]').addClass('active');
  6.             }
  7.         });



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.