Handling the “Enter” / “Return” key in Chrome

前端 未结 3 842
猫巷女王i
猫巷女王i 2021-01-19 02:52

I have an AJAX-y type page. When the user clicks \"GO\" I need to execute a specific javascript function. I also want to simulate the \"GO\" click when a user hits \"Enter\"

3条回答
  •  迷失自我
    2021-01-19 03:15

    Try returning false directly after your if statement (which calls goButton()).

    See an example here: Using jQuery to prevent form submit when enter is pressed

提交回复
热议问题