Step 1:Create index.html file and implement below code.
<form action="">
Site Name:
<input type="text" name="SiteName" value="Bajarangisoft">
<br>
<br> Contributor name:
<input type="text" name="ContributorName" value="Bsoft">
<br>
</form>
<!-- click on this button -->
<button class="btn btn-success">Click here!</button>
Step 2:Implement jQuery to use serialize() method.
<script>
$(document).ready(function() {
$("button").click(function() {
$("#d").text($("form").serialize());
});
});
</script>
Complete Code For Using Serialize Method In JQuery
<!DOCTYPE html>
<html>
<head>
<title>How To Use Serialize Method In JQuery With Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<style>
body {
background: black;
}
</style>
<body>
<div class="container">
<br><br><br>
<div class="text-center">
<h1 id="color" style="color: White;">Use Serialize Method In JQuery</h1>
</div>
<br>
<div class="col-md-2"></div>
<div class="col-md-8">
<div class="well">
<form action="">
Site Name:
<input type="text" name="SiteName" value="Bajarangisoft">
<br>
<br> Contributor name:
<input type="text" name="ContributorName" value="Bsoft">
<br>
</form>
<!-- click on this button -->
<button class="btn btn-success">Click here!</button>
<div id="d"></div>
<script>
$(document).ready(function () {
$("button").click(function () {
$("#d").text($("form").serialize());
});
});
</script>
</div>
</div>
<div class="col-md-2"></div>
</div>
</body>
</html>