admin管理员组文章数量:1384229
I have a textbox that's being automatically focused with jQuery when an element is clicked:
my_item.find('input').focus();
It works in Firefox and Chrome as expected: the input area is focused and I can begin typing in it. In Safari the behavior is different though. I click the element, the input is focused, I start to type in the box, and it only lets me type one character. After the first character of input is typed, the input box loses focus and further typing doesn't work unless it's manually clicked for focus again.
I've found questions about focus()
and Safari working strangely but I think this is a different issue. I've tried the solutions suggested there, such as e.preventdefault()
on mouseup
and similar, with no effect.
How can I get my focused text input area to remain focused while I'm typing in Safari?
I have a textbox that's being automatically focused with jQuery when an element is clicked:
my_item.find('input').focus();
It works in Firefox and Chrome as expected: the input area is focused and I can begin typing in it. In Safari the behavior is different though. I click the element, the input is focused, I start to type in the box, and it only lets me type one character. After the first character of input is typed, the input box loses focus and further typing doesn't work unless it's manually clicked for focus again.
I've found questions about focus()
and Safari working strangely but I think this is a different issue. I've tried the solutions suggested there, such as e.preventdefault()
on mouseup
and similar, with no effect.
How can I get my focused text input area to remain focused while I'm typing in Safari?
Share Improve this question edited Mar 30, 2020 at 16:54 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked Jan 21, 2015 at 15:29 bethbeth 2,0064 gold badges24 silver badges39 bronze badges1 Answer
Reset to default 10The question is a bit old, but i recently had the same problem so this is what i´ve found. Check if your css rules blocks the touch callout. If you have any rule like this try to remove and then try typing again
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
本文标签: javascriptjQueryfocused textbox loses focus after one character of input in SafariStack Overflow
版权声明:本文标题:javascript - jQuery-focused textbox loses focus after one character of input in Safari - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744465436a2607485.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论