<p>Select me and click input</p> <input id="i1" type="text" onmousedown="document.getElementById('i1').value = document.getSelection().toString()" />