How to advance to the next form input when the current input has a value?

前端 未结 10 1430
傲寒
傲寒 2020-11-30 04:08

I am having a form with lots of entries. I would like to change my focus to the next textbox, once I entered the value in the current textbox. and want to continue this proc

10条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-30 04:23

    In vanilla JS:

    function keydownFunc(event) {
          var x = event.keyCode;        
          if (x == 13) {
            try{
                var nextInput = event.target.parentElement.nextElementSibling.childNodes[0];
                nextInput.focus();
              }catch (error){
                console.log(error)
              }
        }
    

提交回复
热议问题