【发布时间】:2020-06-21 20:12:45
【问题描述】:
我正在为 iPad 开发一个 PhoneGap-App。在一个屏幕上,您必须填写一个包含大约 20 个文本字段的表格。由于输入字段仅对点击事件做出反应(延迟时间不长但令人讨厌),我尝试了以下操作:
$('input[type="text"], input[type=number], input[type=date], input[type="tel"], input[type=password], input[type="email"], input[type="url"], textarea, select').live("touchend", function(e) {
if(!swipe) {
$(this).focus();
}
swipe = false;
return false;
});
(我在touchmove 事件中检查滑动)
这可行,但现在我想阻止输入上的原始点击事件。
问题是,当我使用.focus() 方法激活一个输入字段时,键盘会弹出并将页面向上滑动一点,然后click 事件被触发并激活另一个输入字段在我的下方一点点所需的输入。
为了防止点击我已经尝试过:
$('input[type="text"], input[type=number], input[type=date], input[type="tel"], input[type=password], input[type="email"], input[type="url"], textarea, select').live("click", function(e) {
return false;
});
但这也行不通:(
是否有其他技巧可以在我触摸后立即激活输入字段而不会有任何延迟?
【问题讨论】:
-
已经一年了..你应该指定正确的答案
标签: javascript jquery cordova dom-events