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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:45:53+00:00 2026-06-07T04:45:53+00:00

I am coding on top of a framework which I have no control of,

  • 0

I am coding on top of a framework which I have no control of, so need to work around a limitation of what is being generated.

I’m trying to do a jquery UI accordion, but need the accordion to include the two elements following the header, not just one.

For example, the code being spat out is (with a bunch in the middle removed):

<h2>HEADER</h2>
<div>ITEM DESCRIPTION</div> 
<fieldset>
    <legend>Prices</legend>
    <div class="prices">
        <div class="productline" ><label>Price:</label>
                    <div  class="amount">$97.50</div></div>

    </div>
</fieldset>

That all needs to go into the single accordion item, but at the moment the accordion uses the h2 as the header, the div with the description as the accordion content, and then the fieldset after is left outside the accordion. As I can’t control the code being generated to wrap them both in a div, is there a way to tell the accordion to use two items following the header, rather than one?

The jquery I’m using is:

$(function() {
    $( ".productindex" ).accordion({
        active: false,
        collapsible: true,
        autoHeight: true,
        header: 'li>form>h2'
    });
});

To further complicate things, some items don’t have descriptions, so if any script could accomodate the initial div before the fieldset potentially not existing, that would be great – however worst case I can just make sure every item has a description.

Thanks for 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-07T04:45:54+00:00Added an answer on June 7, 2026 at 4:45 am

    Per my initial comment, you could grab everything that needs to be “accordion content” and wrap it all up in an appropriate element in order for the accordion function to work.

    It would take knowing the surrounding structure of your HTML in order to decide the best selector to use to grab those elements. Let’s imagine that your structure somewhat resembles the demo on the jQuery UI site, except with your unchangeable markup instead of a div:

    <h2>HEADER</h2>
    <div>ITEM DESCRIPTION</div> 
    <fieldset>
        <legend>Prices</legend>
        <div class="prices">
            <div class="productline" >
                <label>Price:</label>
                   <div  class="amount">$97.50</div>
            </div>
        </div>
    </fieldset>
    
    <h2>HEADER</h2>
    // whoops, no description!
    <fieldset>
        <legend>Prices</legend>
        <div class="prices">
            <div class="productline" >
                <label>Price:</label>
                   <div  class="amount">$105.50</div>
            </div>
        </div>
    </fieldset>
    

    We can use the h2 nodes as our entry points for selection. What you really want to do is select everything available until the next h2 (it will also end when there are no more h2 in that branch of the DOM tree). By the very nature of this kind of selection, it won’t matter if you have item descriptions, or other elements. Then we add a new wrapper around ALL found elements.

    I don’t know if this is the most well-factored code (people don’t generally like using .each() but I find it handy here), but here’s what I came up with:

    var headers = $('h2');
    headers.each( function() {
      var toWrap = $(this).nextUntil('h2');
      toWrap.wrapAll('<div class="wrapped" />');
    });
    

    Judging from the jQuery UI documentation, you don’t need any class on the wrapping div, I just included one to facilitate this jsFiddle demonstration:

    demo: http://jsfiddle.net/StUWc/1/

    Just for the sake of being thorough, after the wrapAll function, your DOM becomes something that could be represented by this markup:

    <h2>HEADER</h2>
    <div class="wrapped">
      <fieldset>
        <legend>Prices</legend>
        <div class="prices">
            <div class="productline" >
                <label>Price:</label>
                   <div  class="amount">$97.50</div>
            </div>
        </div>
      </fieldset>
    </div>
    
    <h2>HEADER</h2>
    <div class="wrapped">
      <fieldset>
        <legend>Prices</legend>
        <div class="prices">
            <div class="productline" >
                <label>Price:</label>
                   <div  class="amount">$105.50</div>
            </div>
        </div>
      </fieldset>
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

OK so I have # -*- coding: utf-8 -*- at the top of my
CSS code: top:45; left:98; float:right; position:absolute;z-index:2; I have done the above coding for a
I have made a navbar at the top of my website which contains multiple
I have the following coding: <div class=product-top-icons> <div class=energy-rating-1><img src=http://www.justhome.co/skin/frontend/default/just2011/images/assets/<?php echo $_product->getAttributeText('energy_rating_one');?>.jpg></div> <div class=energy-rating-2><img
I have decided to start coding using OOP and a PHP framework. I have
Duplicate : Design & Coding - top to bottom or bottom to top? I
Coding Platform ASP.NET 4.0 WebForms on IIS7.5 If I request a page blahblah.aspx which
Coding i came around to check for the vararg performance of Java. I write
When coding, I use Dropbox to sync folder in which I keep my projects
I have a top navigation and a side one Home | Tours | Booking

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.