首页 > 代码库 > 长按按钮事件函数
长按按钮事件函数
这里是代码的逻辑编写部分
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
$.fn.longPress = function (fn) { var timeout = undefined; var $ this = this ; alert( this .length); for ( var i = 0;i<$ this .length;i++){ $ this [i].addEventListener( ‘touchstart‘ , function (event) { timeout = setTimeout(fn, 800); }, false ); $ this [i].addEventListener( ‘touchend‘ , function (event) { clearTimeout(timeout); }, false ); } } |
代码的代用部分,其中select是你所要获取的元素
1
2
3
|
$(select).longPress( function (index){ alert( "你已长按" ); }); |
长按按钮事件函数
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。