jQuery
submit()
The submit event occurs when a form is submitted.This event can
only be used on <form> elements.The submit() method triggers the submit
event, or attaches a function to run when a submit event occurs.so we can say
that jQuery submit event is sent to the element when the user attempts to
submit a form.
This event is only attached to the <form> element. Forms can
be submitted either by clicking on the submit button or by pressing the enter
button on the keyboard when that certain form elements have focus. When the
submit event occurs, the submit() method attaches a function with it to run.
Styntex:-
|
$(selector).submit()
|
Example :-
|
<!DOCTYPE
html>
<html>
<head>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("form").submit(function(){
alert("Submitted");
});
});
</script>
</head>
<body>
<form
action="">
First
name: <input type="text" name="FirstName"
value="Nitin Kumar"><br>
Last
name: <input type="text" name="LastName"
value="Chauhan"><br>
<input
type="submit" value="Submit">
</form>
</body>
</html>
|