How to trigger an input event with jQuery?
问题 I want to add 'a' to the value of input when click a button Here is my code(with jQuery 1.4.4): $("#button").click(function(){ $("#input").trigger("focus"); var e = jQuery.Event("keypress"); e.which = '97'; $("#input").trigger(e); }) However, it seems only to trigger 'focus' event ,but failed to 'keypress'. 回答1: like this?? Sorry, I'm confused with your writings.. $("#button").click(function(){ $("#input").trigger("keypress") // you can trigger keypress like this if you need to.. .val