Select all div text in single click in JavaScript
Here is the code for selecting a div content through javascript with single click of button or mouse click, just copy and paste javascript code given bellow and call the function selectText at the button click and pass the parameter divid.
Try Demo Here Click Select:-
<script type="text/javascript">
function
selectText(divid) {
if
(document.selection) {
var
div = document.body.createTextRange();
div.moveToElementText(document.getElementById("divid"));
div.select();
}
else
{
var
div = document.createRange();
div.setStartBefore(document.getElementById("divid"));
div.setEndAfter(document.getElementById("divid"));
window.getSelection().addRange(div);
}
}
</script>