Learnerslesson
   JAVA   
  SPRING  
  SPRINGBOOT  
 HIBERNATE 
  HADOOP  
   HIVE   
   ALGORITHMS   
   PYTHON   
   GO   
   KOTLIN   
   C#   
   RUBY   
   C++   
   HTML   
   CSS   
   JAVA SCRIPT   
   JQUERY   




EVENTS - submit()


The submit() Event gets executed, when a form is submitted.


Note : The 'submit()' Event is only applicable for a form.

Let us simplify with the below example.


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://cdnjs.cloudflare.com/ajax/libs/JQUERY/3.3.1/jquery.min.js"> </script>
	  
      	<script>
      
			$('form').submit( function() { 
            	alert('Form is just submitted')
            });
            
      	</script>      
  	</body>
</html> 


Output :



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.