在jQuery中收集表单中的所有项目

Gre*_*ens 7 forms collections jquery

如何收集jQuery中的所有复选框和下拉列表项以进行保存?

Sco*_*ttE 10

或者,对于最新版本的jquery,您可以使用:

http://docs.jquery.com/Ajax/serialize - 到URL编码的字符串person.name=john&person.age=20

要么

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


kar*_*m79 3

一种方法是使用 jQuery Form插件,如下所示:

$('#myFormId').formSerialize(); 
Run Code Online (Sandbox Code Playgroud)

来自formSerialize API 文档

Serializes the form into a query string. This method will return a string in the format: name1=value1&name2=value2
Run Code Online (Sandbox Code Playgroud)