Home > Web Front-end > Front-end Q&A > What is the submit method in jquery

What is the submit method in jquery

WBOY
Release: 2022-04-15 11:13:45
Original
3198 people have browsed it

In jquery, the submit method is a method used to trigger form events; this method can trigger a submit event, or specify a function to be run when a submit event occurs. A submit event will occur when the form is submitted. Syntax is "element object.submit(function)".

What is the submit method in jquery

The operating environment of this tutorial: windows10 system, jquery3.2.1 version, Dell G3 computer.

submit method in jquery

When the form is submitted, the submit event occurs.

This event only applies to

elements.

Thesubmit() method triggers the submit event, or specifies the function to be run when the submit event occurs.

Trigger the submit event of the selected element:

$(selector).submit()
Copy after login

Add a function to the submit event:

$(selector).submit(function)
Copy after login

function Optional. Specifies the function to be run when the submit event is triggered.

The example is as follows:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>123</title> 
<script src="js/jquery.min.js">
</script>
<script>
$(document).ready(function(){
  $("form").submit(function(){
    alert("提交");
  });
});
</script>
</head>
<body>
<form action="">
First name: 
<input type="text" name="FirstName" value="Mickey"><br>
Last name: 
<input type="text" name="LastName" value="Mouse"><br>
<input type="submit" value="提交">
</form> 
</body>
</html>
Copy after login

Output result:

What is the submit method in jquery

After clicking the button:

What is the submit method in jquery

Recommended related video tutorials: jQuery video tutorial

The above is the detailed content of What is the submit method in jquery. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template