jQuery Mobile Collapsible heading Option
jQuery Mobile is a web-based technology and great building UI interfaces for the webpages that can be used to make responsive content for websites that can be accessed on all types of smartphones, tablets, and desktops.
In this article, we will be using the jQuery Mobile Collapsible heading option to get or set the header for the collapsible. The header will be the first immediate child element in the collapsible container that matches the provided selector.
Syntax: The below syntax is used to initialize the collapsible with the heading option.
$( ".selector" ).collapsible({ heading: ".mycollapsibleheading" });
-
Get the default option:
var heading = $( ".selector" ) .collapsible( "option", "heading" );
-
Set the default option:
$( ".selector" ).collapsible( "option", "heading", ".mycollapsibleheading" );
CDN Links: Add the following jQuery Mobile scripts that you will need in 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 demonstrates the jQuery Mobile Collapsible heading option.
HTML
<!doctype html> < html lang = "en" > < head > < meta charset = "utf-8" > < meta name = "viewport" content = "width=device-width, initial-scale=1" > < 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 > $(function () { $("#btn").on('click', function () { var heading = $( "#divID" ).collapsible( "option", "heading" ); $("#gfg").html("Default Heading Option : " + heading); }); }); </ script > </ head > < body > < center > < div data-role = "page" id = "page1" > < div data-role = "header" > < h1 style = "color:green;" >w3wiki</ h1 > < h3 > jQuery Mobile Collapsible Heading Option </ h3 > </ div > < div role = "main" class = "ui-content" > < div data-role = "collapsible" id = "divID" > < 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 > < input type = "button" id = "btn" style = "width:250px;" value = "Heading" > < br > < h4 >< span id = "gfg" ></ span ></ h4 > </ div > </ center > </ body > </ html > |
Output:
Reference: https://api.jquerymobile.com/collapsible/#option-heading