简体   繁体   English

jQuery移动加载页面功能

[英]Jquery mobile load page function

I have 2 pages in jquery mobile html code. 我在jquery移动html代码中有2页。 I want when the school page is loaded it should display an alert 我想在加载学校页面时显示警报

HEADER PART 标题部分

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

This is the pages code 这是页面代码

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>

I also have a javascript code that should show the alert when schoolpage is loaded after the click of school button(#school) in the index page The script is saved as new.js 我还有一个javascript代码,当在索引页面中单击“学校”按钮(#school)后,加载学校页面时应显示警报。脚本保存为new.js

$("#schoolpage").on("pageshow", function(){
        alert("hello");
    });

I have also tried 我也尝试过

     $("#school").on("click", function(){
          alert("hello");
      });

But both don't work 但是两者都不起作用

$("#schoolpage").on("tap", function(){
    alert("hello");
});

Does the above code solve your problem? 上面的代码能解决您的问题吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM