How to go to next textbox when enter is pressed?

后端 未结 4 1012
春和景丽
春和景丽 2021-01-16 16:21

Hi guys I\'m learning Javascript and I would like to ask you guys how can I go to the next textbox after inputing text when I press the enter button in the keyboard. thank y

4条回答
  •  轮回少年
    2021-01-16 17:10

    Try this code :

     $('#inputform').on('keydown', 'input', function (event) {
      if (event.which == 13) {
        event.preventDefault();
        var $this = $(event.target);
        var index = parseFloat($this.attr('data-index'));
        $('[data-index="' + (index + 1).toString() + '"]').focus();
     }
    

    });

    Help Link

提交回复
热议问题