ProAnswers.org

JavaScript to trigger the button's on Enter key in text box?

I have one text input and one button . How can I use JavaScript to trigger the button’s click event when the Enter key is pressed inside the text box?

Well, in jQuery, this would work:

$("#id_of_textbox").keyup(function(event){
if(event.keyCode == 13){
$("#id_of_button").click();
}
});