I'm trying to dynamically set some text in an input field, and then display it, and finally auto-highlight/auto-select it.
If I don't use .val() and instead use value="something" hardcoded on the input it works perfectly.
If I add .val() to the method chain, it just puts the cursor in the box but doesn't highlight the text.
Any idea how I might do this?
In the example below, $(this)
refers to the link they click on "Rename" which causes inline edit box to appear. The .next()
refers to the input.
$(this).hide().next().val(oldName).show().focus();