What the best way to simulate the user pressing "enter"? $(element).keypress() doesn't seem to allow me to pass in the actual key that was pressed.
+3
A:
e = jQuery.Event("keypress")
e.which = 13 //choose the one you want
$("#theInputToTest").trigger(e)
redsquare
2010-07-18 19:00:40
Thanks redsquare. This solution wasn't obvious to me from the docs -- http://api.jquery.com/trigger/. They show they usage as .trigger( eventType, extraParameters ). Should I have been able to figure that out based on the docs? Is this an officially supported feature.
morgancodes
2010-07-18 19:23:13
@morgancodes, I guess not easily no, it is not explained but hinted at lower down.
redsquare
2010-07-19 01:47:56