简体   繁体   中英

Trigger Enter Button on focus on input field

I have input field and i want to trigger keyboard enter button when user focus on that input. Is there anyway to do the same in jQuery or javascript?

Try this:

$('#some-input').keypress(function(event){
  if(event.keyCode == 13){
    $('#my-button').click();
  }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM