Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to submit a form using jQuery click event?
To submit a form using jQuery click event, you need to detect the submit event. Let’s submit a form using click event and without using click event.
Example
You can try to run the following code to learn how to submit a form using jQuery click event −
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(function() {
$('#submit1').click(function(e) {
e.preventDefault();
$("#Demo").submit();
});
$('#submit2').click(function(e) {
e.preventDefault();
$("#Demo").submit();
});
});
});
</script>
</head>
<body>
<form action="javascript:alert('submitted');" method="post" id="Demo">
<label>Team</label>
<input type="text" name="name" value="" />
<input type="submit" name="submitme" value="Submit" id="submit1" />
<p><a href="#" id="submit2">Submit</a></p>
</form>
</body>
</html>Advertisements