Sending/printing a key with jQuery.Trigger
i think i have read every page google knows about which has these keywords, and nothing works for me.
what i have is a form input, and a button next to it [not submit], and what i want is for the button click to trigger an 'enter' key click. [this will respectively run another function which is already working..]
i've tried
<input id='inputBtn' type='button' .... onclick='$('#otherInput').trigger('keypress',[13]);' >
and also putting it in a function and then running it from onclick, or making a
$('#inputBtn').click(function().....
nothing works for me ple开发者_开发百科ase help!!
$('input').trigger({
type: 'keypress',
which: 13
});
--EDIT--
you might want to extend that with
keyCode: 13,
charCode: 13
etc.
You might need to provide some example code. I can't think of any reason you couldn't just have the second function (that runs when enter is pressed) being called by the click event on your button.
function onEnter()
{
//Do something
}
jQuery("#inputButton").live("click",onEnter());
Should work.
精彩评论