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

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

So the code that I have so far is:

&
12条回答
  •  无人及你
    2020-12-04 09:09

    This should do it, I am using jQuery you can write plain javascript.
    Replace sendMessage() with your functionality.

    $('#addLinks').keypress(function(e) {
        if (e.which == 13) {
            sendMessage();
            e.preventDefault();
        }
    });
    

提交回复
热议问题