JQuery Expand Collapse Menu Example

Today, We want to share with you JQuery Expand Collapse Menu Example.In this post we will show you bootstrap collapse,jquery collapse, hear for jquery expand collapse div plus minus we will give you demo and example for implement.In this post, we will learn about html expand collapse text without javascript with an example.

JQuery Expand Collapse Menu Example

There are the Following The simple About JQuery Expand Collapse Menu Example Full Information With Example and source code.

As I will cover this Post with live Working example to develop ul li expand collapse jquery, so the some expand all collapse all bootstrap for this example is following below.

Example 1: jQuery Accordion example with expand/collapse

Jquery expand collapse plus minus
HTML structure

<h2>How to add simple expand/collapse all functionality</h2>
<div class="container">
    <div class="header"><span>Expand</span>

    </div>
    <div class="content">
        <ul>
            <li>jquery expand collapse div plus minus.</li>
            <li>expand and collapse div using jquery example.</li>
            <li>html expand collapse text without javascript.</li>
            <li>jQuery expandable div with plus and minus icons.</li>
            <li>expand/collapse table rows with JQuery </li>
        </ul>
    </div>
</div>

CSS Part

.container .content {
    display: none;
    padding : 5px;
}

jQuery Part

$(".header").click(function () {

    $header = $(this);
    $content = $header.next();
    $content.slideToggle(500, function () {
        $header.text(function () {
            return $content.is(":visible") ? "Collapse" : "Expand";
        });
    });

});

Example 2: jQuery Expand Collapse All

Full Example : HTML Part

With demo: https://codepen.io/Sp00ky/pen/zBZZvq

<div class="container">
  <div class="accordion-option">
    <h3 class="title">Lorem Ipsum</h3>
    <a href="javascript:void(0)" class="toggle-accordion active" accordion-id="#accordion"></a>
  </div>
  <div class="clearfix"></div>
  <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
    <div class="panel panel-default">
      <div class="panel-heading" role="tab" id="headingOne">
        <h4 class="panel-title">
        <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
          Exam Center Item #1
        </a>
      </h4>
      </div>
      <div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
        <div class="panel-body">
          Examples of the bootstrap collapse,jquery collapse,ul li expand collapse jquery, expand all collapse all bootstrap, simple expand collapse jquery, bootstrap collapse, collapse all div, collapse all javascript, expand and collapse table rows in html, html expand collapse text without javascript, expand and collapse div using jquery example, onclick expand div width, expand collapse html code, jquery accordion collapse all, jquery expand collapse div plus minus.
        </div>
      </div>
    </div>
    <div class="panel panel-default">
      <div class="panel-heading" role="tab" id="headingTwo">
        <h4 class="panel-title">
        <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="true" aria-controls="collapseTwo">
          Exam Center Item #2
        </a>
      </h4>
      </div>
      <div id="collapseTwo" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingTwo">
        <div class="panel-body">
          Examples of the bootstrap collapse,jquery collapse,ul li expand collapse jquery, expand all collapse all bootstrap, simple expand collapse jquery, bootstrap collapse, collapse all div, collapse all javascript, expand and collapse table rows in html, html expand collapse text without javascript, expand and collapse div using jquery example, onclick expand div width, expand collapse html code, jquery accordion collapse all, jquery expand collapse div plus minus.
        </div>
      </div>
    </div>
    <div class="panel panel-default">
      <div class="panel-heading" role="tab" id="headingThree">
        <h4 class="panel-title">
        <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseThree" aria-expanded="true" aria-controls="collapseThree">
          Exam Center Item #3
        </a>
      </h4>
      </div>
      <div id="collapseThree" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingThree">
        <div class="panel-body">
          Examples of the bootstrap collapse,jquery collapse,ul li expand collapse jquery, expand all collapse all bootstrap, simple expand collapse jquery, bootstrap collapse, collapse all div, collapse all javascript, expand and collapse table rows in html, html expand collapse text without javascript, expand and collapse div using jquery example, onclick expand div width, expand collapse html code, jquery accordion collapse all, jquery expand collapse div plus minus.
        </div>
      </div>
    </div>
  </div>
</div>

jQuery Part

$(document).ready(function() {

  $(".toggle-accordion").on("click", function() {
    var examCenterId = $(this).attr("accordion-id"),
      numPanelOpen = $(examCenterId + ' .collapse.in').length;
    
    $(this).toggleClass("active");

    if (numPanelOpen == 0) {
      openAllPanels(examCenterId);
    } else {
      closeAllPanels(examCenterId);
    }
  })

  openAllPanels = function(aId) {
    console.log("setAllPanelOpen");
    $(aId + ' .panel-collapse:not(".in")').collapse('show');
  }
  closeAllPanels = function(aId) {
    console.log("setAllPanelclose");
    $(aId + ' .panel-collapse.in').collapse('hide');
  }
     
});

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about JQuery Expand Collapse Menu Example.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.


Related FAQ

Here are some more FAQ related to this Article:

  1.   Angularjs multiple Check and uncheck all checkbox
  2.   Difference between break and continue
  3.   How to Open URL in New Tab using EmberJS
  4.   Simple Vue Input Array Models Example
  5.   BOOTSTRAP ACCORDION WITH PLUS MINUS ICON
  6.   Get Parent Elements With CSS and jQuery
  7.   Laravel Ajax Bootstrap Toggle switch Update MySQL
  8.   Laravel Left join get last record of right table in MYSQL
  9.   gotoxy function in c++ header file
  10.   Vue.js Tutorial for beginners