- //JQ移动端页面监听单击、长按、拖动事件,直接看代码:
- <div class="box">按钮</div>
- <script>
- $(function() {
- //console.log($('.box'));
- $(".box").on({
- touchstart: function(e) {
- //长按触发事件
- timeOutEvent = setTimeout(function() {
- timeOutEvent = 0;
- alert("你长按了");
- }, 1000)
- },
- touchmove: function() {
- clearTimeout(timeOutEvent);
- timeOutEvent = 0;
- alert('移动了')
- },
- touchend: function() {
- clearTimeout(timeOutEvent);
- if (timeOutEvent != 0) {
- alert("你点击了");
- }
- return false;
- }
- });
- });
- </script>
以上就是JQ监听单击、长按、拖动事件的详细内容,更多关于JQ监听单击、长按、拖动事件的资料请关注九品源码其它相关文章!