jQuery Mobile Collapsible expand Events
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 >w3wiki</ 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 >w3wiki</ h3 > < p > w3wiki is a computer science portal for Beginner. 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
Contact Us