hamish hamish - 7 months ago 24
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>


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

var button = document.getElementById("go");
button.addEventListener("click", function(){