Reputation: 79
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" />
Upvotes: 0
Views: 119
Reputation: 55750
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.
Upvotes: 1
Reputation: 6052
With jQuery you can use the select
function:
$("input").select();
Upvotes: 1