What is the best way to simulate a user entering text in a text input box in JS and/or jQuery?
I don\'t want to actually put text in the input box,
I thought I would draw your attention that in the specific context where a listener was defined within a jQuery plugin, then the only thing that successfully simulated the keypress event for me, eventually caught by that listener, was to use setTimeout(). e.g.
setTimeout(function() { $("#txtName").keypress() } , 1000);
Any use of $("#txtName").keypress()
was ignored, although placed at the end of the .ready() function
. No particular DOM supplement was being created asynchronously anyway.