What is the best way (and I presume simplest way) to place the cursor at the end of the text in a input text element via JavaScript - after focus has been set to the element
If you set the value first and then set the focus, the cursor will always appear at the end.
$("#search-button").click(function (event) { event.preventDefault(); $('#textbox').val('this'); $("#textbox").focus(); return false; });
Here is the fiddle to test https://jsfiddle.net/5on50caf/1/