How to trigger an input event with jQuery? -
I want to add 'a' to the value of input when I click on a button
This is my Code is (with jQuery 1.4.4):
$ ("# button"). Click (function () {$ ("# input"). Trigger ("focus"); var e = JQuery.Event ("keypress"); e.which = '97'; $ ("# input"). Trigger (e);}) However, this was the only trigger 'focus' event, but 'keypress' failed.
this way ?? Sorry, I'm confused with your articles ..
Click $ ("# button") (function () {$ ("# input"). Trigger ("keypress") / / If you need .., then you can trigger such a keypad .val (function (i, val) {return val + 'a';});}); Reference:
Comments
Post a Comment