The submit() Event gets executed, when a form is submitted.
Let us simplify with the below example.
<html>
<head>
<title> My First Programme </title>
</head>
<body>
<h1> JQuery </h1>
<form action = "submit">
Type Something and click on the submit button : <input type = "text"> <br/><br/>
<input type = "submit">
</form>
<script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"> </script>
<script>
$('form').submit( function() {
alert('Form is just submitted')
});
</script>
</body>
</html>
So, if you look at the above code, we have a <form> element,
<form action = "submit"> Type Something and click on the submit button : <input type = "text"> <br/><br/> <input type = "submit"> </form>
Inside the <form> element, we have an <input> element, that accepts a text.
<input type = "text">
And there is a submit button,
<input type = "submit">
Now, if we take a look at the JQuery statement,
$('form').submit( function() {
alert('Form is just submitted')
});That locates the <form> element and when you click on the submit button, and the submit() event gets triggered.
$('form').submit(...);And the anonymous function gets executed.
function() {
alert('Form is just submitted')
}Displaying the alert, Form is just submitted.