serialise()

Serializes a form into a JavaScript object.

serialize()

Serializes a form into a JavaScript object, capturing input values based on name attributes.

<form id="myForm">
  <input type="text" name="username" value="JohnDoe">
  <input type="email" name="email" value="john@example.com">
  <input type="radio" name="gender" value="male" checked>
  <input type="radio" name="gender" value="female">
  <select name="country">
    <option value="US" selected>United States</option>
    <option value="CA">Canada</option>
  </select>
  <button type="submit">Submit</button>
</form>

Usage:

const formData = $('#myForm').serialize();
console.log(formData);
/* Output:
{
  username: "JohnDoe",
  email: "john@example.com",
  gender: "male",
  country: "US"
}
*/

Last updated