JavaScript Highlight Text Code: Highlight all Text in a Textarea Box
We all know HTML textarea boxes. They are perfect for feedback or contact forms on your website or blog - but also for delivering code or text conveniently to the reader. This JavaScript highlight text code especially comes in handy if you are writing HTML, CSS, PHP, or JavaScript tutorials, or other web design tutorials. It comes in even more handy to the reader if they only click once on the text box, and they have the whole text inside highlighted, ready to copy to their clipboard!
Well, it’s not hard to do this at all - all you need is a simple line of JavaScript code.
JavaScript Highlight Text
Simply add this JavaScript snippet to the ‘textarea’ tag as an attribute:
onclick="javascript:select();"
It should look something like this:
<textarea cols=”50″ rows=”3″ onclick=”javascript:select();”>I love beeex.net!</textarea>
And this is the result:
There you go! We hope this was the JavaScript highlight text code you were looking for ![]()
Spread the word
if you liked this post. Thank you!




