Click to Hightlight all text: It’s Easier than you think.
If you want your users to click on a text area and automatically highlight all of the text, there is a very simple way to do it. This does not require external javascript at all. It’s no "copy code" button, but if the user clicks inside the text area, this bitt of code will hightlight all of the text in that textfield.
Add the following code to any < textarea > tag:
onclick="javascript:select();"
Example:
<textarea cols="50" rows="3" onclick="javascript:select();"> Highlight this text</textarea>


















This is a nice little snippet of Javascript. I’ve put it to great use on my site. Thanks.
Thanks! Found this really useful.
Thanks! I’ve been looking for this script for a while.
[...] Click to Hightlight all text: It’s Easier than you think. | BittBox Click to Hightlight all text: It’s Easier than you think. Posted on January 7th, 2007 by BittBox. If you want your users to click on a text area and [...]
thanks !
thanks !
It’s no “copy code” button, but if the user clicks inside the text area, this bitt of code will hightlight all of the text in that textfield.
this very good for me thanks for this post
Thanks – that is a really helpful snippet of code. It will be especially helpful when creating code sample boxes.
thanks…
cool .. nice script
Thx.It’s useful!