如何获取jquery mobile中显示的页面的“id”

How to obtain the "id" of the Page which is shown in jquery mobile

本文关键字:显示 id mobile 何获取 获取 jquery      更新时间:2023-09-26

我在html中有这样的各种页面

<body onload="init()">
<div data-role="page" id="home">
<div data-role="header">
<h1>Here is the index page.</h1>
</div>
<div data-role="content">
<p><center>Below you may transition to our other pages.</center></p>
<a href="#about" data-ajax="false" data-role="button" data-inline="true">About  Me</a>
</div>
</div>
<div data-role="page" id="about">
<div data-role="header">
<h1>About Us</h1>
</div>
<div data-role="content">
<a href="#home" data-ajax="false" data-role="button" data-inline="true">Back Home</a>
</div>
</div>
</body>

现在我需要获取当前显示的页面的 ID...怎么做?

你试过吗:$.mobile.activePage.attr('id')

以下

任何一项:

$('div:jqmData(role="page").ui-page-active').attr('id');
$('.ui-page-active').attr('id');

也应该做。