Results 1 to 7 of 7

Thread: Making an Accordion Control?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Making an Accordion Control?

    I'm using JQuery to create an Accordion control. The problem that I'm having is that when I run my webapp, 1 section of the Accordion control is open. I have a total of 4 sections (<div>'s) but everytime I run it, the 1st <div> is always open. I'm using it as a Sidebar menu control and want all the sections to be closed by default. How can this be done?

    Thanks,
    Blake

  2. #2
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: Making an Accordion Control?

    hmm... without seeing the code or a demo of it, I won't be able to say any solutions. I believe, others would also be like me.


    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  3. #3
    Frenzied Member tr333's Avatar
    Join Date
    Nov 2004
    Location
    /dev/st0
    Posts
    1,605

    Re: Making an Accordion Control?

    Are you using a third-party jQuery plugin for this (eg. jQuery UI Accordion)? Any chance of putting an test/example up on http://jsfiddle.net/?
    CSS layout comes in to the 21st century with flexbox!
    Just another Perl hacker,

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Making an Accordion Control?

    I'll see what I can do...
    Blake

  5. #5
    Member
    Join Date
    Jul 2019
    Location
    Ahmedabad
    Posts
    56

    Re: Making an Accordion Control?

    You try this query of making an accordian:
    Code:
    <script>
    var acc = document.getElementsByClassName("accordion");
    var i;
    
    for (i = 0; i < acc.length; i++) {
      acc[i].addEventListener("click", function() {
        this.classList.toggle("active");
        var panel = this.nextElementSibling;
        if (panel.style.display === "block") {
          panel.style.display = "none";
        } else {
          panel.style.display = "block";
        }
      });
    }
    </script>
    < advertising removed by moderator >

  6. #6
    Member
    Join Date
    Jul 2019
    Location
    Ahmedabad
    Posts
    56

    Re: Making an Accordion Control?

    You try this query of making an accordian:
    Code:
    <script>
    var acc = document.getElementsByClassName("accordion");
    var i;
    
    for (i = 0; i < acc.length; i++) {
      acc[i].addEventListener("click", function() {
        this.classList.toggle("active");
        var panel = this.nextElementSibling;
        if (panel.style.display === "block") {
          panel.style.display = "none";
        } else {
          panel.style.display = "block";
        }
      });
    }
    </script>
    < advertising removed by moderator >

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Making an Accordion Control?

    tr333...I used the example from the link you provided and made modifications! Works great! Thanks!
    Blake

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width