Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery submit() method

jQuery submit() method

jQuery event methods jQuery event methods

Example

Display an alert box when the form is submitted:

$("form").submit(function(){

    alert("Submitted");

});

Try it »


Definition and Usage

The submit event occurs when the form is submitted.

This event only applies to

.

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


Syntax

Trigger the submit event of the selected element:

$(

selector

).submit()

Try it

Add a function to the submit event:

$(

selector

).submit(

function

)

Try it

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

More examples

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


jQuery event methods jQuery event methods