Jquery Mobile事件
on()方法用于添加事件处理程序
1.Touch类事件
在用户触摸屏幕时触发
1.1 tap事件 用户敲击某个元素时发生
$("p").on("tap",function(){
$(this).hide();
})
1.2 taphold事件 用户敲击某个元素并保持一秒被触发
$("p").on("taphold",function(){
$(this).hide();
})
1.3 swipeleft 用户在某个元素上左滑动超过30px时触发
$("p").on("swipeleft",function(){
alert("You swiped left!");
});
2.滚动事件
2.1 scrollstart 事件在用户开始滚动页面时被触发
$(document).on("scrollstart",function(){
alert("开始滚动!");
});
2.2 scrollstop 事件在用户停止滚动页面时被触发
$(document).on("scrollstop",function(){
alert("停止滚动!");
});
3.方向事件
orientationchange 事件 用户水平或垂直旋转屏幕时触发
使用orientationchange 事件,需要把它添加到window对象
$(window).on("orientationchange",function(){
alert("方向已改变!");
});
由于该事件与window对象绑定,就有window.orientation属性
if(window.orientation==0){
说明屏幕是portrait的
}
提示:window.orientation 属性对 portrait 视图返回 0,对 landscape 视图返回 90 或 -90
4.页面事件
在 jQuery Mobile 中与页面打交道的事件被分为四类:
- Page Initialization - 在页面创建前,当页面创建时,以及在页面初始化之后
- Page Load/Unload - 当外部页面加载时、卸载时或遭遇失败时
- Page Transition - 在页面过渡之前和之后
- Page Change - 当页面被更改,或遭遇失败时
4.1 Initialization事件
| 事件 | 描述 |
|---|---|
| pagebeforecreate | 当页面即将初始化,并且在 jQuery Mobile 已开始增强页面之前,触发该事件。 |
| pagecreate | 当页面已创建,但增强完成之前,触发该事件。 |
| pageinit | 当页面已初始化,并且在 jQuery Mobile 已完成页面增强之后,触发该事件。 |
$(document).on("pagebeforecreate",function(event){
alert("触发 pagebeforecreate 事件!");
});
$(document).on("pagecreate",function(event){
alert("触发 pagecreate 事件!");
});
$(document).on("pageinit",function(event){
alert("触发 pageinit 事件!")
});
4.2 Load事件 外部页面加载
| 事件 | 描述 |
|---|---|
| pagebeforeload | 在任何页面加载请求作出之前触发。 |
| pageload | 在页面已成功加载并插入 DOM 后触发。 |
| pageloadfailed | 如果页面加载请求失败,则触发该事件。默认地,将显示 "Error Loading Page" 消息。 |
$(document).on("pageload",function(event,data){
alert("触发 pageload 事件!\nURL: " + data.url);
});
$(document).on("pageloadfailed",function(event,data){
alert("抱歉,被请求页面不存在。");
});
4.3 过渡事件 从一页过渡到下一页时触发
| 事件 | 描述 |
|---|---|
| pagebeforeshow | 在“去的”页面触发,在过渡动画开始前。 |
| pageshow | 在“去的”页面触发,在过渡动画完成后。 |
| pagebeforehide | 在“来的”页面触发,在过渡动画开始前。 |
| pagehide | 在“来的”页面触发,在过渡动画完成后。 |
$(document).on("pagebeforeshow","#pagetwo",function(){ // 当进入页面二时
alert("页面二即将显示");
});
$(document).on("pageshow","#pagetwo",function(){ // 当进入页面二时
alert("现在显示页面二");
});
$(document).on("pagebeforehide","#pagetwo",function(){ // 当离开页面二时
alert("页面二即将隐藏");
});
$(document).on("pagehide","#pagetwo",function(){ // 当离开页面二时
alert("现在隐藏页面二");
});
Jquery Mobile事件的更多相关文章
- [转]使用 jQuery Mobile 与 HTML5 开发 Web App —— jQuery Mobile 事件详解
在前文<使用 jQuery Mobile 与 HTML5 开发 Web App —— jQuery Mobile 默认配置与事件基础>中,Kayo 对 jQuery Mobile 事件的基 ...
- jQuery Mobile事件,开发全解+完美注释
全栈工程师开发手册 (作者:栾鹏) jQuery Mobile事件全解 jQuery Mobile 所有class选项 jQuery Mobile 所有data-*选项 jQuery Mobile事件 ...
- jquery mobile Touch事件
Touch事件在用户触摸屏幕(页面)时触发 1.jquery mobile tap tap事件在用户敲击某个元素时触发 $("p").on("tap",fucn ...
- jQuery Mobile 页面事件
jQuery Mobile 页面事件 在 jQuery Mobile 中与页面打交道的事件被分为四类: Page Initialization - 在页面创建前,当页面创建时,以及在页面初始化之后 P ...
- jQuery Mobile学习笔记
1.获取jQuery mobile 文件,访问jQuerymobile网站下载 (貌似使用jquery mobile后,jquery会自动在网页中添加一些class类,第一次知道的我是被吓呆的!!) ...
- jQuery Mobile笔记
1.获取jQuery mobile 文件,访问jQuerymobile网站下载 (貌似使用jquery mobile后,jquery会自动在网页中添加一些class类,第一次知道的我是被吓呆的!!) ...
- 第十三篇、jQuery Mobile
API-->搜索data 0.page data-transition="slide" // 页面切换效果 data-position="fixed" / ...
- jQuery Mobile 入门基础教程
jQuery Mobile是jQuery在手机上和平板设备上的版本.jQuery Mobile 不仅会给主流移动平台带来jQuery核心库,而且会发布一个完整统一的jQuery移动UI框架. jQue ...
- jQuery Mobile 所有class选项,开发全解+完美注释
全栈工程师开发手册 (作者:栾鹏) jQuery Mobile事件全解 jQuery Mobile 所有class选项 jQuery Mobile 所有data-*选项 jQuery Mobile 所 ...
随机推荐
- 如何在网页中用echarts图表插件做出静态呈现效果
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- git 提交的步骤
1. git init //初始化仓库 2. git add .(文件name) //添加文件到本地仓库 3. git commit -m "first commit" / ...
- mysql group by 对多个字段进行分组
在平时的开发任务中我们经常会用到MYSQL的GROUP BY分组, 用来获取数据表中以分组字段为依据的统计数据.比如有一个学生选课表,表结构如下: Table: Subject_Selection S ...
- debug错误
Description "opt_design" can fail with error messages similar to the following: opt_design ...
- codeforces362B
Petya and Staircases CodeForces - 362B 题意: 一个小男孩要上楼梯,他一次可以走1个台阶或2个台阶或3个台阶,但是有一些台阶是脏的,他不想走在脏台阶上.一共有n个 ...
- JarvisOJ Basic Base64?
GUYDIMZVGQ2DMN3CGRQTONJXGM3TINLGG42DGMZXGM3TINLGGY4DGNBXGYZTGNLGGY3DGNBWMU3WI=== 题目非常具有迷惑性,我一开始以为就是一 ...
- 洛谷 P1498 南蛮图腾
题目描述 自从到了南蛮之地,孔明不仅把孟获收拾的服服帖帖,而且还发现了不少少数民族的智慧,他发现少数民族的图腾往往有着一种分形的效果,在得到了酋长的传授后,孔明掌握了不少绘图技术,但唯独不会画他们的图 ...
- Codeforces963C Frequency of String 【字符串】【AC自动机】
题目大意: 给一个串s和很多模式串,对每个模式串求s的一个最短的子串使得这个子串中包含至少k个该模式串. 题目分析: 均摊分析,有sqrt(n)种长度不同的模式串,所以有关的串只有msqrt(n)种. ...
- codeforces 997C.Sky Full of Stars
题目链接:codeforces 997C.Sky Full of Stars 一道很简单(?)的推式子题 直接求显然不现实,我们考虑容斥 记\(f(i,j)\)为该方阵中至少有\(i\)行和\(j\) ...
- codeforces553C Love Triangles
题目链接:codeforces553C Love Triangles 我们来看一下对于一个合法三角形可能出现的边 我们发现,在确定了两边之后,第三条边是什么也就随之确定了 我们用\(1\)表示\(lo ...