Button type “button” vs. “submit”

前端 未结 6 1868
北荒
北荒 2020-11-30 06:04

Is there a difference between a button with type=\"button\" vs type=\"submit\"? Are there functional differences, or is it just a desc

6条回答
  •  爱一瞬间的悲伤
    2020-11-30 06:20

    They have different default behaviour regarding submitting form data to the server The button has an attribute named "type" and can contain those values:

    submit: Has default behaviour of submitting the form data to the server. This is the default if the attribute is not specified, or if the attribute is dynamically changed to an empty or invalid value.

    button: The button has no default behavior. It can have client-side scripts associated with the element's events, which are triggered when the events occur.

提交回复
热议问题