hamish hamish - 1 year ago 62
HTML Question

How to keep the insertion point in a text input when button is clicked

I am trying to make a program and I need the insertion point to go back to the text input when a button is clicked. Any ideas, thanks.

<input type="text" name="fname" id="name">
<button id="go">Go</button>

Answer Source

You can do it with JavaScript by attaching an event listener to the button. Fiddle.

var button = document.getElementById("go");
button.addEventListener("click", function(){
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download