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 542839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:29:19+00:00 2026-05-13T10:29:19+00:00

I am trying to open an accordion based on a link i send to

  • 0

I am trying to open an accordion based on a link i send to the page

This is my url

services.html#branding

I am using the following code in the head:

 <script type="text/javascript">
      $(document).ready(function(){
     $('#accordion').accordion({collapsible: true, animated: 'slide', autoHeight: false, navigation: true, active : 'false'});
      });
  </script>

And the accordion looks like:

<div id="accordion">
<h3 id="branding"><a href="#">Branding</a></h3>
<div>
<p>Does your business have a</p>
</div>
<h3><a href="#print">Print</a></h3>
<div>
<p>Brochures</a></p>
</div>
</div>

Any help would be greatly appreciated…
http://docs.jquery.com/UI/Accordion

  • 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-05-13T10:29:20+00:00Added an answer on May 13, 2026 at 10:29 am

    Oh I see Jeff reported that the current UI version is broken, but I actually had a solution using the current version…

    HTML

    <div id="accordion">
     <h3><a href="#branding">Branding</a></h3>
     <div>
      <p>Does your business have a</p>
     </div>
     <h3><a href="#print">Print</a></h3>
      <div>
      <p>Brochures</p>
      </div>
    </div>
    

    Script

    $(function(){
     $('#accordion').accordion({
      collapsible: true,
      animated: 'slide',
      autoHeight: false,
      navigation: true
     });
     // open content that matches the hash
     var hash = window.location.hash;
     var thash = hash.substring(hash.lastIndexOf('#'), hash.length);
     $('#accordion').find('a[href*='+ thash + ']').closest('h3').trigger('click');
    })
    

    I used a[href$=...] originally, but changed it to a[href*=...]… either will work


    Update: the navigation option was removed from jQuery UI 1.10.0, so use this method:

    CSS

    .accordion {
      position: relative;
    }
    .accordion .accordion-link {
      position: absolute;
      right: 1%;
      margin-top: 16px;
      z-index: 1;
      width: 12px;
      height: 12px;
      background: url(link.png) center center no-repeat; /* approx 12x12 link icon */
    }
    

    Script

    var hashId = 0,
      $accordion = $('#accordion');
    if (window.location.hash) {
      $accordion.children('h3').each(function(i){
        var txt = $(this).text().toLowerCase().replace(/\s+/g,'_');
        this.id = txt;
        if (txt === window.location.hash.slice(1)) {
          hashId = i;
        }
      });
    }
    
    $accordion.accordion({
      active: hashId,
      animate: false,
      heightStyle: 'content',
      collapsible: true,
      create: function( event, ui ) {
        $accordion.children('h3').each(function(i){
          $(this).before('<a class="accordion-link link" data-index="' + i + '" href="#' + this.id + '"></a>');
        });
        $accordion.find('.accordion-link').click(function(){
          $accordion.accordion( "option", "active", $(this).data('index') );
        });
      }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm trying to build a website using a jquery horizontal accordion following this handy
I am trying open a new window using url.Action. And the new Window url
The site I'm trying to spider is using the javascript: request.open(POST, url, true); To
I'm trying to read a binary file with the following code: open(F, <$file) ||
im trying to open a file using StreamReader and ive to set a Encoding,
I'm trying to open a folder in explorer with a file selected. The following
I'm trying to open a Microsoft Excel file in a C# program using the
I am trying to open a process handle in C# using the OpenProcess function
I am trying to open one window from another using makeKeyAndOrderFront. The new window
I am trying to figure why the nav links wont open the accordion. I

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.