How to trigger HTML button when you press Enter in textbox?

后端 未结 12 1271
悲哀的现实
悲哀的现实 2020-12-04 08:13

So the code that I have so far is:

&
12条回答
  •  醉梦人生
    2020-12-04 09:03

    You could add an event handler to your input like so:

    document.getElementById('addLinks').onkeypress=function(e){
        if(e.keyCode==13){
            document.getElementById('linkadd').click();
        }
    }
    

提交回复
热议问题