Sign In : Sign Up : Blog : Search: Language : Help :
This website is now frozen, please migrate your content to BotLibre.com or BotLibre.biz
Java Script

How to select the text in a text input when a user clicks on it?

by jamesssss posted Aug 18 2014, 8:00

You can make a text input select the existing text when a user clicks on it with a little JavaScript.
You can use the "onFocus" event with the value "this.select();"

<input name="my-input" type="text" value="enter your value here" onFocus="this.select();" onMouseOut="javascript:return false;"/>

Try it out:

Id: 282207
Tags: text, focus, select
Posted: Aug 18 2014, 8:00
Updated: Mar 27 2015, 15:46
Replies: 0
Views: 1242, today: 1, week: 6, month: 11
I'm sure
Flag graphic as offensive, or in violation of site rules