在我们滑动手机的时候,如果LI或者DIV标签可以点击,那么在移动端给用户一个效果

/*id为添加效果LI上的UL的ID,或者是当前DIV的ID*/
function doTouchPublic(id){
setTimeout(function(){
var obj=document.getElementById(id);
touchPublic.tagUltagDiv(obj);
},300);
};
var touchPublic={
tagUltagDiv:function(obj){
var objAll;
/*如果对象为UL,那么给LI添加事件,否则给DIV当前对象添加事件*/
if(obj.tagName=="UL"){
objAll=obj.childNodes;
}else{
objAll=obj;
}
touchPublic.touchMoveEndIf(objAll);
},
/*li做委托事件,on为JQ中委托事件*/
touchMoveEndIf:function(obj){ $(obj).on('touchstart',function(){
touchPublic.touchObjstart(this,"objRowOver");
})
/*触摸滑动,e.preventDefault();是为了让end触发*/
$(obj).on('touchmove',function(){
touchPublic.touchObjend(this,"objRowOver");
});
/*触摸离开*/
$(obj).on('touchend',function(){
touchPublic.touchObjend(this,"objRowOver");
}); },
touchObjstart:function(that,color){
$(that).addClass(color);
},
touchObjend:function(that,color){
if($(that).attr('class')==color){
$(that).removeClass(color);
}
}
}

手机端touchstart,touchmove,touchend事件,优化用户划入某个可以点击LI的效果的更多相关文章

  1. 移动端的touchstart,touchmove,touchend事件中的获取当前touch位置

    前提:touchstart,touchmove,touchend这三个事件可以通过原生和jq绑定. 原生:document.querySelector("#aa").addEven ...

  2. touchstart,touchmove,touchend事件 写法

    jQuery写法: $('#id').on('touchstart',function(e) { var _touch = e.originalEvent.targetTouches[0]; var ...

  3. touchstart和touchend事件

    touchstart和touchend事件 移动互联网是未来的发展趋势,现在国内很多互联网大佬都在争取移动这一块大饼,如微信及支付宝是目前比较成功的例子,当然还有各种APP和web运用. 由于公司的需 ...

  4. 获取touchstart,touchmove,touchend 坐标

    简单说下如何用jQuery 和 js原生代码获取touchstart,touchmove,touchend 坐标值: jQuery 代码: $('#id').on('touchstart',funct ...

  5. touchstart,touchmove,touchend触摸事件的小小实践心得

    近段时间使用html5开发一个公司内部应用,而触摸事件必然是移动应用中所必须的,刚开始以为移动设备上或许也会支持鼠标事件,原来是不支持的,好在webkit内核的移动浏览器支持touch事件,并且打包成 ...

  6. 移动端touchstart,touchmove,touchend

    近段时间使用html5开发一个公司内部应用,而触摸事件必然是移动应用中所必须的,刚开始以为移动设备上或许也会支持鼠标事件,原来是不支持的,好在webkit内核的移动浏览器支持touch事件,并且打包成 ...

  7. js 手机端触发事事件、javascript手机端/移动端触发事件

    处理Touch事件能让你跟踪用户的每一根手指的位置.你可以绑定以下四种Touch事件: touchstart: // 手指放到屏幕上的时候触发 touchmove: // 手指在屏幕上移动的时候触发 ...

  8. 手机端html5触屏事件(touch事件)

    touchstart:触摸开始的时候触发 touchmove:手指在屏幕上滑动的时候触发 touchend:触摸结束的时候触发 而每个触摸事件都包括了三个触摸列表,每个列表里包含了对应的一系列触摸点( ...

  9. (转)手机端html5触屏事件(touch事件)

    本文转载自:http://blog.sina.com.cn/s/blog_51048da70101f0ex.html touchstart:触摸开始的时候触发 touchmove:手指在屏幕上滑动的时 ...

随机推荐

  1. java学习笔记--IO流

    第十二章大纲: I/O input/output 输入/输出 一.创建文件,借助File类来实现 file.createNewFile() : 创建文件 file.exists() : 判断文件是否存 ...

  2. 数据结构-链表逆置(c++模板类实现)

    链表结点类模板定义: template <class T> class SingleList; template <class T> class Node { private: ...

  3. jquery 中的一写常用方法

    $('form').submit(); // 表单提交 window.parent.location.reload(); // 子窗口刷新父页面 window.location.reload(); / ...

  4. 【leetcode】Pascal's Triangle I & II (middle)

    Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Retur ...

  5. NEFU 505 超级红与黑 (高斯消元)

    题目链接 中文题,改下模板构造一下就能过了,数据有点水,不过还是需要自由变元枚举的. #include <iostream> #include <cstdio> #includ ...

  6. 用jquery怎么实现点击显示,再一次点击隐藏

    html代码: <button>点击</button> <div class="div"></div> css代码: <sty ...

  7. 解决webstorm乱码

    新的web前端学习群,120342833,欢迎大家一起学习,以前在web学习群里的看到了加下..

  8. Codeforces Round #370 (Div. 2)(简单逻辑,比较水)

    C. Memory and De-Evolution time limit per test 2 seconds memory limit per test 256 megabytes input s ...

  9. Xcode开发中的6个小技巧

    Xcode是iPhone和iPad开发者用来编码或者开发iOS app的IDE.Xcode有很多小巧但很有用的功能,很多时候我们可能没有注意到它们,也或者我们没有在合适的水平使用这些功能简化我们的iO ...

  10. React Native实例

    本文主要包括以下内容 View组件的实例 Text组件实例 Navigator组件实例 TextInput组件实例 View组件的实例 效果如下 代码如下 /** * Sample React Nat ...