Open In App

jQuery Mobile Pagecontainer change() Method

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 change() Method. This method is used to change from one page to another page.



Syntax:

Parameter: This method accepts the following parameters:

Return type: The return type of this method is an object.

CDN Link: The following jQuery Mobile scripts will be needed for your project so we need to add these scripts to 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 uses of the jQuery Mobile Pagecontainer change() Method.




<!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 change() Method</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>
        </div>
        <div data-role="page" id="GFG2">
            <h1 style="color:green;">
                GeeksforGeeks
            </h1>
            <h3>jQuery Mobile Pagecontainer change() Method</h3>
            <div data-role="header">
                <h1>Second Page</h1>
            </div>
            <input type="button" id="Button"
                value="Change to First Page">
        </div>
    </center>
    <script>
        $(document).ready(function () {
            $("#Button").on('click', function () {
                $(":mobile-pagecontainer")
                    .pagecontainer( "change", $("#GFG1" ));
            });
        });
    </script>
</body>
  
</html>

Output:

jQuery Mobile Pagecontainer change() Method

Reference: https://api.jquerymobile.com/pagecontainer/#method-change


Article Tags :