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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:28:18+00:00 2026-06-08T19:28:18+00:00

I am using Jquery Accordian in my page, Here is the HTML, <div class=forms-cont>

  • 0

I am using Jquery Accordian in my page, Here is the HTML,

<div class="forms-cont">
    <h5>
        Accordian Examples</h5>
    <div class="accordian">
        <div>
            <h2 class="sch-hdr">
                Header One</h2>
            <div class="sch-cont levelOne">
                <p>
                    this is a title text - level one</p>
            </div>
        </div>
        <div class="">
            <h2 class="sch-hdr">
                Header Two</h2>
            <div class="sch-cont levelOne">
                <p>
                    This is another title text - level one
                </p>
                <div class="martop10">
                    <h3 class="subgr-hdr">
                        Staff</h3>
                    <div class="sch-cont levelTwo">
                        <p>
                            This is an inner text
                        </p>
                    </div>
                </div>
                <div class="">
                    <h3 class="subgr-hdr">
                        Manager</h3>
                    <div class="sch-cont levelTwo">
                        <p>
                            This is an inner text
                        </p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

In this, i need to append an anchor tag for the accordian to work, and here is my jquery,

 $(document).ready(function() { 

    // Accordian Main 
    $('.accordion h2, .accordion h3').addClass('closed'); 
    $('.levelOne,.levelTwo').hide(); 
    $('.accordion h2, .accordion h3').each(function () { 
            $(this).html(function() { 
            var headertext = '<a href="#">' + $(this).html() + '</a>'; 
            return headertext; 
        }); 
    }); 

    // Level 1 Accordian 
    $(".accordion h2 a").click(function() { 
        alert('hi');
            $(this).next(".levelOne").slideToggle("slow"); 
            $(this).toggleClass("closed"); 
            return false; 
    }); 
    // Level 2 Accordian 
    $('.accordion h3 a').click(function() { 
            $(this).parent().next(".levelTwo").slideToggle("slow"); 
            $(this).parent().toggleClass("closed"); 
            return false; 
    }); 
  });

But i am unable to append anchor in H2 and H3. Any help?

  • 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-08T19:28:21+00:00Added an answer on June 8, 2026 at 7:28 pm

    EDIT: Sorry, is wrapInner() instead if wrap().

    Three things:

    1) You don’t need an .each(), simply:

    $('.accordion h2, .accordion h3').wrapInner('<a href="#"></a>');
    

    2) There is a typo in your html:

    <div class="accordian">  <-- accordion?
    

    3) A “parent()” is missing on the “h2 a” click event:

    $(".accordion h2 a").click(function() { 
            $(this).next(".levelOne").slideToggle("slow"); <-- actual
    
    $(".accordion h2 a").click(function() { 
            $(this).parent().next(".levelOne").slideToggle("slow"); <-- with parent()
    

    And then it will work 🙂

    jsFiddle: http://jsfiddle.net/fy2uM/2

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

Sidebar

Related Questions

I am using JQuery Accordion. I have this page here: http://www.hauppauge.com/site/support/support_colossus.html#tabs-6 What happens is
I'm using the Jquery-ui. I have different droppable ul(s) in one page, and different
I'm using jquery .clone() to add HTML to my page according to user clicks.
I am using Lazy Load Jquery plugin here on my test page: http://bloghutsbeta.blogspot.com/2012/03/testing-2_04.html And
http://mindfulintegrations.com/signiacapital/accordian.php I am using Jquery Accordion UI and if you look at the above
I am using jQuery Accordion here and find some strange behavior when opening a
I'm using jQuery Tool's tabs an accordion as per here: http://www.jquerytools.org/demos/tabs/accordion.htm The whole thing
Here's the specs: ASP.NET 3.5 using ASP.NET AJAX AJAX Control Toolkit jQuery 1.3.2 web
I am using following a tutorial from here: http://www.shopdev.co.uk/blog/cookies-with-jquery-designing-collapsible-layouts/ This is the script I
I'm using JQuery 1.4.2 for an accordion effect on my website. All but one

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.