How to simulate tab key with enter key on javascript

后端 未结 2 1610
耶瑟儿~
耶瑟儿~ 2021-01-24 12:27
    

        
2条回答
  •  长发绾君心
    2021-01-24 13:19

    return event.keycode is effectively return 9, and even return event will not help, as returning the event does not mean that will be handled properly, what you probably want to do instead is to take the enter event and then manually change focus to the next required field:

    function onDataBound(e) {
      $("#batchgrid").on("click", "td", function (e) {
        $("input").on("keydown", function (event) {
          event.preventDefault();
          if (event.keyCode == 13) {
            $(this).next("input, textarea").focus()
          }
        });
      });
    }
    

提交回复
热议问题