This question has been asked in a few different formats but I can\'t get any of the answers to work in my scenario.
I am using jQuery to implement command history wh
set the value first. then set the focus. when it focuses, it will use the value that exists at the time of focus, so your value must be set first.
this logic works for me with an application that populates an with the value of a clicked . val() is set first. then focus()
$('button').on('click','',function(){
var value = $(this).attr('value');
$('input[name=item1]').val(value);
$('input[name=item1]').focus();
});