I cannot find a solution in 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?
<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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.