Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

jQuery UI menu collapseAll() Method

  • Last Updated : 19 Mar, 2021

jQuery UI consists of GUI widgets, visual effects, and themes implemented using jQuery, CSS, and HTML. jQuery UI is great for building UI interfaces for the webpages. jQuery UI menu is a Themeable menu that is used with mouse and keyboard interactions for navigating between pages. In this article, we will use collapseAll method to collapse all the sub-menu. 


$(".selector").menu( "collapseAll" );

Approach: First, add jQuery UI scripts needed for your project.

<link href = “” rel = “stylesheet”>
<script src = “”></script>
<script src = “”></script>

Example: In this example, we will be using menu collapseAll() Method.


<!doctype html>
<html lang="en">
    <meta charset="utf-8">
    <link href=
        .ui-menu {
            width: 200px;
        $(function() {
            var menu = $("#gfg").menu();
            $(menu).mouseleave(function() {
    <h1>jQuery UI | menu collapseAll method</h1>
    <ul id="gfg">
        <li><a href="#">Menu</a>
                <li><a href="#">Submenu</a>
                        <li><a href="#">


  • With collapseAll method
  • Without collapseAll method.


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!