How can I automatically trigger an enter key press event after a certain action is executed?

后端 未结 4 2061
耶瑟儿~
耶瑟儿~ 2021-01-02 10:04

I\'m writing some unit test in my web apps and I want to automatically trigger an Enter key pressed event from my page after for example a download to text file b

4条回答
  •  余生分开走
    2021-01-02 11:00

    If you're talking about automatically entering an Enter key to trigger a submit event, you can use this instead:

    $("#formID").submit();
    


    To trigger this event after a button has been pressed, try this:

    $("#buttonID").click(function() {
        $("#formID").submit(); // submits form
    });
    

提交回复
热议问题