![](/img/trans.png)
[英]Load function on pageshow and stop on leaving the page with jQuery Mobile
[英]Jquery mobile load page function
我在jquery移動html代碼中有2頁。 我想在加載學校頁面時顯示警報
標題部分
<link href="jquery-mobile/jquery.mobile.theme-1.3.0.min.css" rel="stylesheet" type="text/css">
<link href="jquery-mobile/jquery.mobile.structure-1.3.0.min.css" rel="stylesheet" type="text/css">
<script src="jquery-mobile/jquery-1.11.1.min.js" type="text/javascript"></script>
<script src="jquery-mobile/jquery.mobile-1.3.0.min.js" type="text/javascript"></script>
<link href="custom/scripts/new.js" rel="stylesheet" type="text/javascript">
這是頁面代碼
div data-role="page" id="indexpage" data-theme="e">
<div data-role="header" data-theme="b">
<h1>S-Select</h1>
</div>
<div data-role="content">
<div class="row">
<a href="#schoolpage" data-transition="flip" id="school">Schools</a>
</div>
</div>
</div>
<div data-role="page" id="schoolpage" data-theme="e">
<div data-role="header" data-theme="e" data-position="fixed">
<a href="#indexpage" data-role="button" data-icon="back" data-rel="back" data-iconpos="notext">Back</a>
<h1>Header</h1>
</div>
<div data-role="content">
school page
</div>
我還有一個javascript代碼,當在索引頁面中單擊“學校”按鈕(#school)后,加載學校頁面時應顯示警報。腳本保存為new.js
$("#schoolpage").on("pageshow", function(){
alert("hello");
});
我也嘗試過
$("#school").on("click", function(){
alert("hello");
});
但是兩者都不起作用
$("#schoolpage").on("tap", function(){
alert("hello");
});
上面的代碼能解決您的問題嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.