Javascript examples for DOM HTML Element:Input Text
Set focus at the end of textbox while typing
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/*w w w .jav a 2 s. c om*/ document.getElementById("focusButton").onclick = function() { var inputElement = document.getElementById("focusText"); var text = inputElement.value; inputElement.value=text; inputElement.focus() } } </script> </head> <body> <input type="text" id="focusText"> <button id="focusButton">Set Focus</button> </body> </html>