加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 创业 > C语言 > 正文

Html5 touch事件

发布时间:2020-12-15 01:23:00 所属栏目:C语言 来源:网络整理
导读:“touch”事件鼠标参数位置: 源生: e.touches[0] JQuery: e.originalEvent.touches[0] 在JQuery使用“touch”事件不能直接绑定: $(...).touchstart(function(){...}); //无效 需要使用“bind()”这类方法来进行绑定 $(...).bind('touchstart',function()

“touch”事件鼠标参数位置:
源生:

e.touches[0]

JQuery:

e.originalEvent.touches[0]

在JQuery使用“touch”事件不能直接绑定:

$(...).touchstart(function(){...});            //无效

需要使用“bind()”这类方法来进行绑定

$(...).bind('touchstart',function(){...});

使用源生JavaScript绑定“touch”事件:

var obj = document.getElementById('...');
obj.addEventListener('touchstart',function(e){...},false);

解除绑定方法为:“removeEventListener()”
在解除绑定的时候参数需与绑定的参数相同,且不能解除 绑定匿名函数的事件,如下:

//无效
obj.addEventListener('touchstart',false);
obj.removeEventListener('touchstart',false);

//有效
obj.addEventListener('touchstart',func,false);

该绑定事件的第三个参数解释:

Html5 “touch”事件详解:

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读