Hello, everyone.

I have a scrollbox that I am needing to select all of the text within it. The code is below.

<div class="all" style="height:480px;width:360px;border:1px solid #ccc;font:16px/26px Georgia, Garamond, Serif;overflow:auto;">

This part of web programming is my weak point. I'm not quite sure what else to try.

If you have any suggestions, I'd be grateful to hear them.

Thanks for reading this,


we can achieve this by using "contenteditable" property and the following java script code

<div contenteditable="true" onclick="document.execCommand('selectAll',false,null)">

Place  your text here 


you can add your styles to this div as usual

let me know if you have any problem

commented: Awesome solution! +1

Much appreciated. Worked perfectly. Is there a way to make a button also select this? If not, that's fine.