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>
<script> $(document).ready(function() { $("button").click(function() { var x = $("form").serializeArray(); $.each(x, function(i, field) { $("#d").append(field.name + ":" + field.value + ":::"); }); }); }); </script>
<!DOCTYPE html> <html> <head> <title>How To Use SerializeArray 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 SerializeArray 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() { var x = $("form").serializeArray(); $.each(x, function(i, field) { $("#d").append(field.name + ":" + field.value + ":::"); }); }); }); </script> </div> </div> <div class="col-md-2"></div> </div> </body> </html>