JQuery1.9 (helper function) --. serializeArray ();

Source: Internet
Author: User
Tags javascript array

. 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 containnameAttribute. 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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.