jQuery submit() Event

jQuery submit event triggers when the user attempts to submit a form. This event is only used in the form element, while submitting a form.

Syntax of submit() Event

$(selector).submit(function) 

The selector is the element on click the submit event trigger. The function is an optional parameter. This function is called when the user hits the submit button.

Example

<form id="frm">
<input type="submit" value="Submit" />
</form>	

<script>
$(document).ready(function(){  
$("#frm").submit(function(){  
alert("This submit event called.");  
});  
});   
</script>

Output of the above code

In the above example, an alert message is displayed when the user submits the form of id 'frm'.





Read more articles


General Knowledge



Learn Popular Language