jQuery submit()Method

jQuery 事件方法jQuery Event Methods

Example

When the form is submitted, display an alert box:

$("form").submit(function(){
alert("Submit");
});

Try it Yourself »

Definition and Usage

When a form is submitted, a submit event occurs.

This event only applies to <form> elements.

The submit() method triggers the submit event, or specifies a function to run when the submit event occurs.


Syntax

Trigger the submit event of the selected elements:

$(selector).submit() Try it Yourself

Add a function to the submit event:

$(selector).submit(function) Try it Yourself

Parameters Description
function Optional. Specifies a function to run when the submit event is triggered.


实例

More Examples

Prevent the default behavior of the submit button
How to use the event.preventDefault() method to prevent the form from being submitted.


jQuery 事件方法jQuery Event Methods

Other Extensions