Button Click event fires when pressing Enter key in different input (no forms)

后端 未结 6 2100
离开以前
离开以前 2020-12-12 21:42

This logic is firing when pressing \"Enter\" in the \"Amount\" input, and I don\'t believe it should (it doesn\'t in Chrome). How can I prevent this, and if not prevent it

6条回答
  •  抹茶落季
    2020-12-12 22:19

    A jQuery based solution that does this for every button is:

     $('button').prop('type', 'button'); // To prevent IE from treating every button as a submit and firing a click() event
    

    However the click event will still bubble up to parent elements for some reason...

提交回复
热议问题