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

  • SEARCH
  • Home
  • 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 7736659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:47:45+00:00 2026-06-01T07:47:45+00:00

so I have this code for tabs in jquery, the href is set to

  • 0

so I have this code for tabs in jquery, the href is set to about, what I want to do is provide a link in the menu that triggers this tab when clicked so http://myurl.com#about

$('#info-nav li').click(function(e) {
    $('#info div').hide();
    $('#info-nav .current').removeClass("current");
    $(this).addClass('current');

    var clicked = $(this).find('a:first').attr('href');
    $('#info ' + clicked).fadeIn('fast');
    e.preventDefault();
 }).eq(0).addClass('current');
  • 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-01T07:47:46+00:00Added an answer on June 1, 2026 at 7:47 am

    I would attach the handler to <a> element instead of <li>

    $('#info-nav li a:first').click(function(e) {
        $('#info div').hide();
        $('#info-nav .current').removeClass("current");
        $(this).closest('li').addClass('current');
    
        var clicked = $(this).attr('href');
        $('#info ' + clicked).fadeIn('fast');
        e.preventDefault();
    
    }).eq(0).closest('li').addClass('current');
    

    so that on DOMready event I would read the hash in the URL (with location.hash) and I would trigger the click event (or the handler with .triggerHandler()) on the element whose href attribute is equal to that hash

    $(function() {
        var hash = location.hash, tgt = $('a[href="' +  hash + '"]');
        if (hash !== '' && tgt.length) {
           tgt.trigger('click');
        }
    });
    

    call the same function on window.onhashchange event (if the link you’re providing is not actually changing the whole page)

    $('window').bind('hashchange', function() {
        var hash = location.hash, tgt = $('a[href="' +  hash + '"]');
        if (hash !== '' && tgt.length) {
           tgt.trigger('click');
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code in jQuery, that I want to reimplement with the prototype
I have the following jquery code that allows me to use tabs, to tab
I have this jQuery ajax navigation tabs plugin that I created using some help
I have created the widget in Jquery mobile for Tabs. I want that when
I have group of jQuery Tabs that are created dynamically. Each tab has an
Actually I am trying to do jquery tabs. I have written a code that
Using jQuery's UI Tabs. This is my code. <div id=tabs> <ul> <li><a href=#tabs-1>Find a
I have this code that performs an ajax call and loads the results into
I have this code: myVariable which I want to change into trace(myVariable: + myVariable);
I am using jQuery UI tabs to have a tab where I can search

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.