The jQuery serializedArray() Method is used to create a JavaScript array of objects by serializing form values. It operates on a jQuery collection of forms and form controls. You can select one or more form elements such as <input>, <textarea> or the form element itself.
Syntax:
$(selector).serializeArray()
Let's take an example of serializeArray() method.
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ var x = $("form").serializeArray(); $.each(x, function(i, field){ $("#results").append(field.name + ":" + field.value + " "); }); }); }); </script> </head> <body> <form action=""> First name: <input type="text" name="FirstName" value="Ajeet"><br> Last name: <input type="text" name="LastName" value="Maurya"><br> </form> <button>Serialize form values</button> <div id="results"></div> </body> </html>