Div contenteditable Click Select All Text execCommand selectAll
Learn to use JavaScript to make selecting text simpler for your site users. We once again turn to execCommand() methods to easily accomplish this task. To see much more use of execCommand() try to catch the series we put out about building a JavaScript WYSIWYG rich text editor.
<html>
<head>
<style>
#div1{border:#666 1px solid; padding:10px;"}
</style>
</head>
<body>
<div id="div1" contenteditable="true" onclick="document.execCommand('selectAll',false,null)">
<p>A lot of code goes here</p>
<p>Many lines of code or whatever</p>
</div>
</body>
</html>