按钮preSS并保持在Android的PhoneGap的行动 [英] Button press and hold for action in Android PhoneGap

查看:168
本文介绍了按钮preSS并保持在Android的PhoneGap的行动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要preform在我的应用程序特定的操作,如果用户presses并持有几秒钟的一个按钮,如果用户的延迟耗尽之前删除按钮的手指,然后这一行动将被取消。我使用的preSS'ontouchstart事件。

I'm need to preform a specific action in my app if the user presses and holds a button for a few second, if the user removes his finger from the button before the delay runs out, then this action will be cancelled. I use 'ontouchstart' event for the press.

有什么办法,我可以做到这一点使用HTML和JavaScript?

Is there any way i can achieve this using html and javascript?

感谢。

推荐答案

下面是一个code片段来实现这一特殊要求,

Here is a code snippets to achieve this particular requirement,

var pressTimer;
$("#btnClick").mouseup(function(){
  clearTimeout(pressTimer);
  return false;
});
$("#btnClick").mousedown(function(){
  pressTimer = window.setTimeout(function() { ... your code here ...},time_delay)
  return false; 
}); 

这篇关于按钮preSS并保持在Android的PhoneGap的行动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆