Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9007649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:44:50+00:00 2026-06-16T01:44:50+00:00

I am using a jQuery tabs implementation and everything works great, however I want

  • 0

I am using a jQuery tabs implementation and everything works great, however I want to be able to link to a URL for example http://www.mydomain.com/tabs.html#tab2 and have the page automatically open on tab 2, heres where I am at so far http://jsfiddle.net/Jmx7k/

<script>
jQuery(document).ready(function() {
    jQuery('#tabs2 li a:not(:first)').addClass('inactive');
    jQuery('.container:not(:first)').hide();

    jQuery('#tabs2 li a').click(function() {
        var t = jQuery(this).attr('href');
        if (jQuery(this).hasClass('inactive')) { //added to not animate when active
            jQuery('#tabs2 li a').addClass('inactive');
            jQuery(this).removeClass('inactive');
            jQuery('.container').hide();
            jQuery(t).fadeIn('slow');
         }
    return false;
}) //end click
});​
</script>
    <div id="tabs2holder">
        <ul id="tabs2">
        <li><a href="#tab1">Test Tab 1</a></li>
        <li><a href="#tab2">Test Tab 2</a></li>
    </ul>
</div>

<div class="container" id="tab1">
    This is test content for tab1
</div>


<div class="container" id="tab2">
     This is test content for tab2
</div>

Could someone point me in the right direction of adding this functionality and also explain why it doesn’t currently do this?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T01:44:51+00:00Added an answer on June 16, 2026 at 1:44 am

    Ok, if you want to create an url with hash-part (e.g. ‘#tab2’) you can get this value with

    var hash = location.hash; // hash = '#tab2'
    

    change your code like this

    jQuery(document).ready(function() {
        jQuery('#tabs2 li a:not(:first)').addClass('inactive');
        jQuery('.container:not(:first)').hide();
    
        jQuery('#tabs2 li a').click(function() {
            var t = jQuery(this).attr('href');
            if (jQuery(this).hasClass('inactive')) { //added to not animate when active
                jQuery('#tabs2 li a').addClass('inactive');
                jQuery(this).removeClass('inactive');
                jQuery('.container').hide();
                jQuery(t).fadeIn('slow');
            }
            return false;
        }); //end click
    
        if (location.hash == '#tab2') {
            // don't forget to put id-attributes to your li-elements
            jQuery('#tablink2 a').trigger('click');
        }
    });​
    

    see also here: http://jsfiddle.net/Jmx7k/8/
    by jsfiddle the hash-attribute is not affecting the javascript-area 🙁 try it in normal context.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can i change http://www.example.com/#home to http://www.example.com/home I'm using jquery tabs Is it possible
I've been using jQuery tabs and I love it. However, if I want to
I am using jquery UI tabs and want to know that , is it
I'm using the jquery tabs plugin and want to have the background a light
At my view i am using Jquery tabs .Initially everthing works fine for me.
I'm using jquery tabs ( http://docs.jquery.com/UI/API/1.7.2/Tabs ). Jquery version 1.3.2 and Jquery UI version
I am using jQuery tabs control on www.quickerbook.imobisoft.eu . On top right corner, under
I need jQuery tabs that will also work with a URL Example I have
I'm using jQuery Tabs UI with standard the tabs structure ( http://jqueryui.com/demos/tabs/ ). I
I'm using jQuery-UI-Tabs to organize data on my web page. However, I've noticed that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.