Skip to content
Related Articles

Related Articles

jQuery Mobile Pagecontainer getActivePage() Method

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 07 Feb, 2022

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 getActivePage() Method. This method is used to return the currently active page.

Syntax:

$( ".selector" ).pagecontainer( "getActivePage" );

Parameter: This method does not accept any parameter.

Return type: This method returns an object value that contains the currently active page.

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 getActivePage() Method.

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 getActivePage() 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>
            <input type="button" id="Button"
                value="Remove the external page">
            <div id="log"></div>
        </div>
        <div data-role="page" id="GFG2">
            <h1 style="color:green;">
                GeeksforGeeks
            </h1>
            <h3>jQuery Mobile Pagecontainer getActivePage() Method</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="Remove the external page">
            <div id="log"></div>
        </div>
    </center>
    <script>
        $(document).ready(function () {
            $("#Button").on('click', function () {
                var page = $(":mobile-pagecontainer")
                    .pagecontainer("getActivePage");
                console.log(page);
            });
        });
    </script>
</body>
  
</html>

Output:

jQuery Mobile Pagecontainer getActivePage() Method

jQuery Mobile Pagecontainer getActivePage() Method

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


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!