Sending / printing a key using jQuery.Trigger

I think I have read every page that Google knows about that these keywords have and nothing is working for me.

that I have a form input and there is a button next to it [not submit] and I want the button to press the button to trigger an 'enter' click. [this is, accordingly, launching another function that is already working.]

I tried

<input id='inputBtn' type='button' .... onclick='$('#otherInput').trigger('keypress',[13]);' >

      

and also put it in a function and then run it from onclick or do

$('#inputBtn').click(function().....

      

nothing works for me please help !!

+2


a source to share


2 answers


$('input').trigger({
  type:  'keypress',
  which:  13
});

      

- EDIT -

you can extend it with



keyCode: 13,
charCode: 13

      

and etc.

+2


a source


You may need to provide some sample code. I can't think of any reason why you couldn't just use a second function (which fires when you press enter) called by a click event on your button.

function onEnter()
{
 //Do something
}

jQuery("#inputButton").live("click",onEnter());

      



Must work.

0


a source







All Articles