jqueryzurb-foundationzurb-foundation-5

unable to use accordion in foundation 5


I am trying to use accordion in foundation 5 but still, it's not working. Can anyone guide me where I am doing wrong

<!DOCTYPE html>
<html>
  <head>
     <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/foundation/5.4.7/css/foundation.min.css">
     <script src = "https://cdnjs.cloudflare.com/ajax/libs/foundation/5.4.7/js/vendor/jquery.js">
     </script>
     <script src = "https://cdnjs.cloudflare.com/ajax/libs/foundation/5.4.7/js/foundation.min.js">
     </script>
     <script src = "https://cdnjs.cloudflare.com/ajax/libs/foundation/5.4.7/js/foundation/foundation.accordion.js">
     </script>

     <script>
    $(document).foundation({
      accordion: {
        callback : function (accordion) {
          console.log(accordion);
        }
      }
    });
  </script>
</head>

<body>

<ul class="small-block-grid-1 medium-block-grid-3">
        <li>
          <ul class="accordion" data-accordion="myAccordionGroup">
            <li class="accordion-navigation">
              <a href="#panel1c">Accordion 1</a>
              <div id="panel1c" class="content">
                Panel 1. Lorem ipsum dolor
              </div>
            </li>
            <li class="accordion-navigation">
              <a href="#panel2c">Accordion 2</a>
              <div id="panel2c" class="content">
                Panel 2. Lorem ipsum dolor
              </div>
            </li>
            <li class="accordion-navigation">
              <a href="#panel3c">Accordion 3</a>
              <div id="panel3c" class="content">
                Panel 3. Lorem ipsum dolor
              </div>
            </li>
          </ul>
        </li>        
</ul>

</body>

</html>

Versions

Foundation.js - 5.4.7
Foundation.css - 5.4.7
foundation.accordion.js - 5.4.7
jquery - 2.1.1


Solution

  • I found the solution that is foundation 5.4.7 doesn't support accordion with ul & li tags. It provides support for 5.5 and above

    https://foundation.zurb.com/sites/docs/v/5.5.3/components/accordion.html

    In order to use an accordion, I need to make use of dl & dd tags