I want to be able to either Press the enter key or click the mouse to submit the info in the inputbox.
Right now when you manually change focus using tab or click with mouse it will submit the info. It is using the jQuery live Click method.
I found this solution for setting focus to a button
Setting focus to a button next to a text box
but I don’t know how to implement that so I can listen using the live click and do either or. A mouse click or the enter button. Any help is appreciated.
example: be able to do this using either the enter button with focus or a mouse click.
$('#theinput').keypress(function(event) {
if (event.keyCode == '13') {
$('#mybutton').click();
event.preventDefault();
}
});
Problem is I don’t know how to convert that example to also use something like this
$('a.button').live('click',function(){
//do stuff here
)};
I would do this using a named function:
This uses the same function for both events without triggering another unnecessary event, which would cause performance issues.