I did my homework and checked lots of questions but still couldn't find something that I can get to work.
I have a search input. When user clicks on example, I want the word "doctor" be written in my search input letter by letter. I could have done that by changing $("#search").val() long ago, but here is the problem. When normally user types into search input autocompletion div is coming out. It is triggered by keydown event. If i just change the val attribute of input, the autocomplete div won't come out, so I need to somehow trigger keydown event so it will come out.
I found this solution:
$("#example").click(function() {
$("#search").focus();
var e = jQuery.Event("keyup");
e.keyCode = 50;
$("#search").trigger(e);
});
but I couldnt get it to work. Any ideas please?
Here is how html looks:
<input type="text" id="search" />
Example: <span id="example">doctor</span>