Jquery移动加载页面功能

时间:2016-02-23 15:46:56

标签: javascript jquery jquery-mobile

我在jquery移动HTML代码中有2页。我想在学校页面加载时它应该显示警告

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

这是页面代码

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");
      });

但两者都不起作用

1 个答案:

答案 0 :(得分:0)

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

以上代码是否解决了您的问题?

相关问题