博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
如何让touchmove之后不触发touchend的事件
阅读量:7051 次
发布时间:2019-06-28

本文共 1092 字,大约阅读时间需要 3 分钟。

手机扫码看效果

不多说,直接上代码

  • 111
  • 222
  • 333
  • 444
  • 555
  • 666
  • 777
  • 888
  • 999
  • 000
  • aaa
  • bbb
  • ccc
  • ddd
  • eee
  • fff
  • ggg
  • hhh
  • iii
  • jjj
  • kkk
  • lll
  • mmm
  • nnn
  • ooo
  • ppp
  • qqq
*{
margin: 0; padding: 0; border: 0;}ul{
list-style: none;}li{
line-height: 2em; border-bottom: 1px solid #eee; width: 100%; text-indent: 2em;}
var UL = document.getElementById('Ul');var moves = true;function Alert(ev){    if(moves)    alert(ev.target.innerHTML)}UL.addEventListener('touchmove',function(){    moves = false;    UL.addEventListener('touchend',function(){        moves = true;    })})UL.addEventListener('touchend', Alert)
原理:
1. 设置一个变量moved来标识是否有移动过,初始值为false;
2. 绑定touchend事件,将moved置为true;
3. 绑定touchmove事件,将moved置为false;
4. 在touchmove事件函数中继续绑定touchend事件,再将moved置为true

---恢复内容结束---

转载于:https://www.cnblogs.com/guojikun/p/6389545.html

你可能感兴趣的文章
Swift设置自动行高
查看>>
171. Excel Sheet Column Number
查看>>
简单深搜
查看>>
关于获取客户端Mac地址
查看>>
紫书 例题 10-9 UVa 1636 (概率计算)
查看>>
51nod 01背包
查看>>
outlook anywhere 配置
查看>>
冲刺一 (day 3)
查看>>
Beep使用
查看>>
关于php网络爬虫phpspider。
查看>>
OpenGL的glRotatef旋转变换函数详解
查看>>
c#中 ==与equals有什么区别
查看>>
Oracle Group By ROLLUP-SubTotal
查看>>
PHP 正则表达式
查看>>
Computer Graphics Research Software
查看>>
nodejs进阶(2)—函数模块调用
查看>>
java面向对象高级分层实例_BaseDao
查看>>
iOS 从相册中拿到 图片名 ,截取后缀,图片名
查看>>
linux+nginx+tomcat负载均衡,实现session同步
查看>>
初始JavaScript Promises之二
查看>>