Home >>jQuery Tutorial >jQuery submit() Method

jQuery submit() Method

jQuery submit() Method

jQuery submit() method in jQuery is used to add a function or triggers the submit event to run when a submit event occurs a form is submitted.

Syntax:

Trigger the submit event for the selected elements:

$(selector).submit()

Attach a function to the submit event:

$(selector).submit(function)

Parameter Values

Parameter Description
function It is an optional parameter and used to specifies the function to run when the submit event is triggered
Here is an Example of jQuery submit() Method:

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("form").submit(function(){
alert("Submitted");
});
});
</script>
</head>
<body>
<form action="">
Fname: <input type="text" name="FName" value="Phptpoint"><br>
Lname: <input type="text" name="LName" value="Classes"><br>
<input type="submit" value="Submit">
</form> 
</body>
</html>

Output:
Fname:
Lname:

No Sidebar ads