jQuery submit() Method - CodingTag
×


jQuery submit()

1295

  • This function in jQuery is used to trigger the submit event or it binds a function to run when a submit event occurs.
  • A submit event happens when an HTML form is submitted. So, this function is only made for HTML <form> element.

Related Topics:

jQuery select
jQuery change

jQuery submit

Syntax:

$(selector).submit() ;

or

If you want to trigger a function in it, the syntax will be:

$(selector).submit(function);

Parameter description:

  • function: It represents the function to run when the submit event is triggered. It is optional.

Example:

<html>
<head>
<title> jQuery Example </title>
<script type = "text/javascript"
src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$(".f").submit(function(){
var val=$(".name").val();
alert("Name submitted sccessfully and the value is : "+val);
});

});
</script>
</head>
<body>

<h2> jQuery Submit Event Example </h2>
<form class="f" method="post" action="">
Name: <input class="name" type="text" name="fullname">
<button type="submit" id="bt">Submit</button>
</form>
</body>
</html>

Output:

When you enter a name and submit,



Best WordPress Hosting


Share:


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price



Leave a Reply


Comments
    Waiting for your comments