Onclick shouldn't trigger form data submission

前端 未结 3 1215
梦谈多话
梦谈多话 2020-12-07 04:20

I just found out that every time onclick event for my

相关标签:
3条回答
  • 2020-12-07 05:02

    Try this..

    onclick="alert('hi!'); return false;"
    
    0 讨论(0)
  • 2020-12-07 05:14

    With jQuery use a span rather than an input, put use the .button call and then set a click event.

    0 讨论(0)
  • 2020-12-07 05:15

    Specify type="button":

    <button type="button" onclick="alert('hi!')">Button</button>
    

    From the linked article:

    This [submit] is the default if the attribute is not specified

    0 讨论(0)
提交回复
热议问题