I have 3 tabs in my ‘my-account’ page of my website.

when you go here for example:
https://mywebsitename.com/my-account/ you will have 3 tabs to choose from.

The problem is that when you go to tab 2 it’s the same URL.

I would like it to be
https://mywebsitename.com/my-account/#tab2

Here is my JS

(function($) {          
       $(document).ready(function(){

        $('ul.tabs li').click(function(){
            var tab_id = $(this).attr('data-tab');

            $('ul.tabs li').removeClass('current');
            $('.tab-content').removeClass('current');

            $(this).addClass('current');
            $("#"+tab_id).addClass('current');
        })

    })
    })(jQuery);

And here is what I have in my wordpress functions.php file

// The tabs in the my account page
function tabs() {
wp_enqueue_script( 'tabs', get_stylesheet_directory_uri() . '/scripts/tabs.js', array( 'jquery' ) );
}
add_action( 'wp_enqueue_scripts', 'tabs' );

Any help will be amazing,

Thank you

Read more here: Unique URL to each tab


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: