【问题标题】:What's the difference of click and focus event between mobile devices and Computers?移动设备和计算机之间的点击和焦点事件有什么区别?
【发布时间】:2015-12-14 18:10:59
【问题描述】:

我实现了这个功能:在完成这个聚焦的输入后跳转到下一个输入(只需要一个字符)。它确实可以在计算机上运行。
我需要意识到,当有人通过键盘输入像“a”这样的字符时,它将专注于下一个输入。我知道如何在计算机上实现它。

if ($(this).val().length === 1){
   $(this).next().focus();
}

而且我知道绑定它的 keyup 方法。 但是在手机上发生了一些不好的事情: 它在手机上不起作用,手机的虚拟键盘在输入后会隐藏
听说点击手机后有300ms的延迟。如何在移动设备上触发焦点或立即点击?

<input type="text" >
<input type="text" >
<input type="text" >
<input type="text" >

【问题讨论】:

  • $(this).next.focus(); ==> $(this).next().focus(); note () of next 我想知道“它确实可以在计算机上运行。”
  • 您可能会改为查看 input 事件。
  • 抱歉,稍有疏忽。但在我的代码上是next()。 @Tushar
  • @Jai 你能告诉我在哪里查找输入事件吗?谢谢!
  • @yaochiqkl 你能用你的代码更新你的问题吗?

标签: javascript jquery html mobile focus


【解决方案1】:

jQuery keyup's 方法应该可以正常工作。

试试这样的:

$.each($(".input"),function(){
	$(this).keyup(function() {
             $(this).next().focus();
        });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input class="input" type="text" />
<input class="input" type="text" />
<input class="input" type="text" />

【讨论】:

  • 我知道使用keyup方法来实现它,它在电脑上运行良好,但在手机上却不行:'(
  • 嗯,我在我的手机(在 jsfiddle 中)上尝试了这个 sn-p,它正在工作:jsfiddle.net/s2pL450L
  • 哦,真的吗?我再查一下,还是谢谢
猜你喜欢
  • 2012-09-07
  • 1970-01-01
  • 2020-11-22
  • 2014-01-17
  • 2012-08-24
  • 2015-01-13
  • 2017-04-04
  • 2011-04-20
相关资源
最近更新 更多