Open In App

jQuery Mobile Pagecontainer themeOption

Last Updated : 30 Jan, 2022
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 Pagecontainer theme option to set the color scheme for the pagecontainer widget. This option accepts a single letter from a-z that maps to the swatches included in the theme.

Syntax: Initializing the pagecontainer theme option.

$( ".selector" ).pagecontainer({
theme: "c"
});
  • Setting the theme option:

    $( ".selector" ).pagecontainer( "option", "theme", "c" );
  • Getting the theme option:

    var themeClass = $( ".selector" ).pagecontainer( "option", "theme" );

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 Pagecontainer theme Option.

HTML




<!doctype html>
<html lang="en">
  
<head>
    <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>
</head>
  
<body>
    <center>
        <div data-role="page" id="GFG1">
            <h1 style="color:green;">
                GeeksforGeeks
            </h1>
            <h3>jQuery Mobile Pagecontainer theme Option</h3>
            <div data-role="header">
                <h1>First Page</h1>
            </div>
            <div role="main">
                <a href="#GFG2" data-transition="slide">
                    Go To Second Page</a>
            </div>
            <input type="button" id="Button" 
                   value="Value of the theme option">
            <div id="log"></div>
        </div>
        <div data-role="page" id="GFG2">
            <h1 style="color:green;">
                GeeksforGeeks
            </h1>
            <h3>jQuery Mobile Pagecontainer theme Option</h3>
            <div data-role="header">
                <h1>Second Page</h1>
            </div>
            <div role="main">
                <a href="#GFG1" data-rel="back" 
                   data-transition="slide">Go Back To First Page</a>
            </div>
            <input type="button" id="Button" 
                   value="Value of the theme option">
            <div id="log"></div>
        </div>
    </center>
    <script>
        $(document).ready(function () {
            $("#GFG2").pagecontainer({
                theme: "c"
            });
            $("#GFG2").pagecontainer(
                "option", "theme", "c");
            $("#Button").on('click', function () {
                var a = $("#GFG2").pagecontainer(
                    "option", "theme"
                );
                $("#log").html(a);
            });
        });
    </script>
</body>
  
</html>


Output:

jQuery Mobile Pagecontainer themeOption

jQuery Mobile Pagecontainer themeOption

Reference: https://api.jquerymobile.com/pagecontainer/#option-theme



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads