简体   繁体   中英

Collect all the items in a form in jQuery

How do I collect all the checkboxes and dropdown list items in jQuery for saving?

Or, for recent versions of jquery you can use:

http://docs.jquery.com/Ajax/serialize - to a URL encoded string person.name=john&person.age=20

or

http://docs.jquery.com/Ajax/serializeArray - to JSON

One way is to use the jQuery Form plugin, like this:

$('#myFormId').formSerialize(); 

From the formSerialize API documentation :

Serializes the form into a query string. This method will return a string in the format: name1=value1&name2=value2

$('#myFormId').formSerialize(); is a plugin and maybe not necessary. The core function serialize() is better.

http://docs.jquery.com/Ajax/serialize

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM