Open In App

jQuery Mobile Collapsible collapse Events

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Share
Report issue
Report

jQuery Mobile is a web-based technology used to make responsive content that can be accessed on all smartphones, tablets, and desktops. In this article, we will be using the jQuery Mobile Collapsible collapse event to trigger when a collapsible widget is collapsed.

Syntax:

  • Initialize the collapsible with the collapse callback specified:

    $( ".selector" ).collapsible({
      expand: function( event, ui ) {}
    });
  • Bind an event listener to the collapsiblecollapse event:

    $( ".selector" ).on( "collapsiblecollapse", 
        function( event, ui ) {} );

 

CDN Link: First, add jQuery Mobile scripts needed for your project.

<link rel=”stylesheet” href=”https://code.jquery.com/mobile/1.5.0-alpha.1/jquery.mobile-1.5.0-alpha.1.min.css”>
<script src=”https://code.jquery.com/jquery-3.2.1.min.js”></script>
<script src=”https://code.jquery.com/mobile/1.5.0-alpha.1/jquery.mobile-1.5.0-alpha.1.min.js”></script>

Example: This example describes the jQuery Mobile Collapsible collapse Event.

HTML




<!doctype html>
<html lang="en">
  
<head>
    <link rel="stylesheet" href=
    <script src=
    </script>
    <script src=
    </script>
  
    <script>
        $(document).ready(function () {
            $("#GFG").on("collapsiblecollapse", function (event, ui) {
                alert("Collapsible Widget Content Collapsed")
            });
        });
    </script>
</head>
  
<body>
    <div data-role="page" id="page1">
        <div data-role="header">
            <h1>GeeksforGeeks</h1>
            <h3>jQuery Mobile Collapsible collapse Event</h3>
        </div>
  
        <div role="main" class="ui-content">
            <div data-role="collapsible" 
                style="width: 400px;" id="GFG">
  
                <h3>GeeksforGeeks</h3>
                <p>
                    GeeksforGeeks is a computer science portal
                    for geeks. It contains well written, well
                    thought and well explained computer science
                    and programming articles, quizzes etc.
                </p>
  
            </div>
        </div>
    </div>
</body>
  
</html>


Output:

Collapsible collapse Events

Reference: https://api.jquerymobile.com/collapsible/#event-collapse



Last Updated : 15 Dec, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads