Enter fires the form submit

前端 未结 2 892
不思量自难忘°
不思量自难忘° 2021-01-22 20:35

I have a div (nice gif displayed as-if it\'s a button), on that div is a piece of JavaScript that handles the ENTER as-if it\'s a click $(this).c

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-22 21:10

    In IE, the default behavior of the enter key on an input element (button type) is a form submit (most of the time).

    You can try to capture the keydown event and check for enter key; if it is then run event.preventDefault().

    Take a look at: https://developer.mozilla.org/en/DOM/event.preventDefault

    If you post some code, I can help you by modifying your code. Post your HTML and relevant JavaScript.

提交回复
热议问题