How do i send a trigger keypress of a particular keyCode eg. "9" event on a TextBox using JQuery programmatically?
This what i intend to do; Programmatically enter a value to a TextBox and then programmatically trigger a tabkey on the TextBox to exit the field.
my code
$("#tags1").val("comp") // Works well
$("#tags1").trigger("keypress",[9]); // Fails!!
Gath
The jQuery documents state that it'll only pass normalized event attributes = the properties of the jQuery.Event object, which don't seem to include event-specific data.
I tried, and couldn't get it to insert text into a textbox even when reusing an event object that a browser keypress created, so it doesn't seem to be possible.
Why can't you just change the value of the textbox, and call blur() to exit it? (Or focus() on the one you want to enter next?)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With