Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can jQuery Event which value be changed?

Tags:

jquery

I would like to change the default behavior on my elements:

$('form input').keypress(function (e) {
  if (e.which == 13) { // ENTER key
    e.setTempDefault(9); // TAB key
    // e.preventDefault();
  }
});

Obviously, setTempDefault does not exist.

All I can find is e.preventDefault();


1 Answers

$('form input').keypress(function (e) {
    if (e.which === 13) {
        e.preventDefault();  
        $(':input').eq( $(this).index(':input') + 1 ).focus();
    }
});

FIDDLE

like image 64
adeneo Avatar answered Feb 16 '26 03:02

adeneo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!