Wireless Army
This is a blog / tips and tricks website for web developers and security researchers.
follow us in feedly


how to select all with a click
by admin
 at 2016-07-25 21:57:00.

this script will allow you to make the user select all the info in a input, textarea or paragraph
<script type="text/javascript">
    // a function to call when clicked
    function selectText(containerid) {
        if (document.selection) {
            var range = document.body.createTextRange();
            range.moveToElementText(document.getElementById(containerid));
            range.select();
        } else if (window.getSelection) {
            var range = document.createRange();
            range.selectNode(document.getElementById(containerid));
            window.getSelection().addRange(range);
        }
    }
</script>
<pre id="selectable" onclick="selectText('selectable')">some text that the user can select by clicking on it</pre>