[英]highlight and select a text of a input with jQuery
I cannot find a solution in stackoverflow. 我无法在stackoverflow中找到解决方案。 I have an input filed and a value.
我有一个输入字段和一个值。 I want the value to be selected and highlighted, so the user can easily copy the text.
我希望选择并突出显示该值,以便用户可以轻松复制文本。 How can I do it with jQuery?
我怎么能用jQuery做到这一点?
<input value="copy this text easily" />
使用jQuery,您可以使用select
函数:
$("input").select();
Try 尝试
$('input').focus()
You may need to change the selector though. 您可能需要更改选择器。 I wrote a generic selector since there in only 1 input in the example.
我写了一个通用选择器,因为在这个例子中只有1个输入。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.