. SerializeArray (); returns an Array
Description:Compile the value of the form Element Used for submission into an array consisting of name and value objects. For example, [{name: a value: 1}, {name: B value: 2},...], this method does not accept any parameters.
.serializeArray()
Method To create a javascript array consisting of objects to encode a JSON string. It can operate on a jQuery object that represents a group of form elements. Form elements can be of the following types:
4 5 6 7
.serializeArray()
The method uses the standard W3C "successful controls" standard to detect which elements should be included. Disabled elements are not included. In addition, the element must containname
Attribute. In addition, the value of the submit button is not serialized. The data of the file selection element will not be serialized.
.serializeArray()
The method can be used to operate the selected form Element Object, for example<input>
,<textarea>
, And<select>
. Another more convenient method is to directly use<form>
Label for serialization:
$ ('Form'). submit (
This will generate the following data structure (console.log
):
Example: Get values from the form, traverse and display them
Results: Single Single2 Multiple Multiple2 Multiple3 check1 check2 radio1 radio2
Demo: