[英]Mobile selecting of text inputs
If i have an input type=text and am viewing it on a mobile device, if I press inside the input and hold down on the text (let's say it's a url), the entire url won't be selected. 如果我有一个输入type = text并正在移动设备上查看它,如果我在输入中按下并按住文本(例如,它是一个URL),则不会选择整个URL。 Only a single word will be.
只有一个字。 I want to be able to easily select the entire text and then copy it.
我希望能够轻松选择整个文本,然后将其复制。 Is there a way to do this in css or html?
有没有办法做到这一点的CSS或HTML? I can select all the text with javascript but then trying to touch down to copy does the same thing, only selects a word.
我可以使用javascript选择所有文本,但是尝试着陆进行复制会做同样的事情,只选择一个单词。
for instance: 例如:
<input type="text" value="http://foo.bar">
I click in the middle and only "foo" gets selected. 我单击中间,只有“ foo”被选中。 I want to select all the text so it's easy to copy
我想选择所有文本,以便于复制
Here you go: 干得好:
$('input').focus(function() {
this.select()
});
$('input').click(function() {
this.focus();this.select()
});
Implemented here: http://jsfiddle.net/4XJDW/ 在此处实现: http : //jsfiddle.net/4XJDW/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.