移动端兼容判断单击和双击事件,费话不想说了,直接上代码:
<input name="double_click" id="double_click" type="hidden" value="" />
<script>
//兼容移动端焦点定位,主要用于兼容安卓班牌的触屏
$(function() {
//console.log($('.box'));
function double_click(){
setTimeout(function() {
$("#double_click").val('')
}, 500)
}
//此处与双击冲突,都会造成,改成任意位置长按,
$("body").on({
touchstart: function(e) {
clickd_id=$(e.target).attr("id");
console.log(clickd_id+"1")
vvl=$("#double_click").val();
if (vvl=='1'){
//console.log("双击")
if (clickd_id=='anniu_index'){
system_out()
}
}else{
//console.log("单击")
}
$("#double_click").val('1')
double_click();
$("#xueyuan_card").focus()
//长按触发事件
timeOutEvent = setTimeout(function() {
timeOutEvent = 0;
$("#xueyuan_card").focus()
}, 1000)
},
touchmove: function(e) {
//clickd_id=$(e.target).attr("id");
//console.log(clickd_id+"2")
clearTimeout(timeOutEvent);
timeOutEvent = 0;
$("#xueyuan_card").focus()
},
touchend: function(e) {
//clickd_id=$(e.target).attr("id");
//console.log(clickd_id+"3")
clearTimeout(timeOutEvent);
if (timeOutEvent != 0) {
$("#xueyuan_card").focus()
}
return false;
}
});
});
</script>
以上就是移动端兼容判断单击和双击事件的详细内容,更多关于移动端兼容判断单击和双击事件的资料请关注九品源码其它相关文章!