In an HTML file, I have a text field and a button. When the button is pressed, text is added to the to text field via plain JavaScript.
HTML:
please input : <input id="city" type="text" name="city" />
<button onclick="myFunction()">click</button>
JavaScript:
function myFunction()
{
var a=document.getElementById("city").value ;
document.getElementById("city").value = a;
}
How to set the focus of the text field to the last entered character by using only plain JavaScript, without jQuery or other libraries?
Thank you in advance.