Open In App

jQuery Mobile Collapsible expand Events

Last Updated : 20 Dec, 2021
Improve
Improve
Like Article
Like
Save
Share
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 expand event to trigger when a collapsible widget is expanded.

Syntax:

Initialize the collapsible with the expand callback specified:

$( ".selector" ).collapsible({
   expand: function( event, ui ) {}
});

 

Bind an event listener to the collapsibleexpand event:

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

Parameters: It contains two parameters as mentioned above and discussed below:

  • event: It accepts Event type value.
  • ui: It accepts object type value. This value is empty as it is used for consistency with other events.

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

<link rel=”stylesheet” href=”//code.jquery.com/mobile/1.5.0-alpha.1/jquery.mobile-1.5.0-alpha.1.min.css”>
<script src=”//code.jquery.com/jquery-3.2.1.min.js”></script>
<script src=”//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 expand Event.

HTML




<!doctype html>
<html lang="en">
  
<head>
    <link rel="stylesheet" href=
"//code.jquery.com/mobile/1.5.0-alpha.1/jquery.mobile-1.5.0-alpha.1.min.css">
    <script src=
"//code.jquery.com/jquery-3.2.1.min.js"></script>
    <script src=
"//code.jquery.com/mobile/1.5.0-alpha.1/jquery.mobile-1.5.0-alpha.1.min.js">
    </script>
    <script>
        $(document).ready(function () {
            $("#GFG").on("collapsibleexpand ", function (event, ui) {
                alert("Start Expanding Content of Collapsible Widget");
            });
        });
    </script>
</head>
  
<body>
    <div data-role="page" id="page1">
        <div data-role="header">
            <h1>GeeksforGeeks</h1>
            <h3>jQuery Mobile Collapsible expand 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:

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



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads