jQuery Mobile Pagecontainer getActivePage()方法

jQuery Mobile Pagecontainer getActivePage()方法

jQuery Mobile是一种基于网络的技术,用于制作可在所有智能手机、平板电脑和台式机上访问的响应式内容。

在这篇文章中,我们将使用jQuery Mobile Pagecontainer getActivePage() 方法。这个方法是用来返回当前的活动页面。

语法:

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

参数:该方法不接受任何参数。

返回类型:该方法返回一个包含当前活动页面的对象值。

CDN链接:你的项目将需要以下jQuery Mobile脚本,所以我们需要将这些脚本添加到你的项目中。

<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>

例子:这个例子描述了jQuery Mobile Pagecontainer getActivePage()方法的用途。

<!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>

输出:

jQuery Mobile Pagecontainer getActivePage()方法

jQuery Mobile Pagecontainer getActivePage()方法

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程