好库网 好库网首页 | 我的好库
JQuery入门

fieldSerialize(true)-JQuery API

发布者:jquery2000
发布日期:2011/4/6 15:31:30   更新日期:2011/4/6 15:31:30
阅读次数:2968
评分:4.80
介绍:fieldSerialize(true) 将jQuery对象中的所有field元素序列化到一个查询字符串中。
正文:

 

fieldSerialize(true)

将jQuery对象中的所有field元素序列化到一个查询字符串中。

 This method will return a string in the format: name1=value1&name2=value2 The successful argument controls whether or not serialization is limited to 'successful' controls (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls). The default value of the successful argument is true.

 

返回值

String

 

参数

true (successful): if only successful controls should be serialized (default is true) 

示例

说明:

Collect the data from all successful input elements into a query string

 

jQuery 代码:

var data = $("input").formSerialize(); 

--------------------------------------------------------------------------------

 

说明:

Collect the data from all successful radio input elements into a query string

 

jQuery 代码:

var data = $(":radio").formSerialize(); 

--------------------------------------------------------------------------------

 

说明:

Collect the data from all successful checkbox input elements in myForm into a query string

 

jQuery 代码:

var data = $("#myForm :checkbox").formSerialize(); 

--------------------------------------------------------------------------------

 

说明:

Collect the data from all checkbox elements in myForm (even the unchecked ones) into a query string

 

jQuery 代码:

var data = $("#myForm :checkbox").formSerialize(false); 

--------------------------------------------------------------------------------

 

说明:

Collect the data from all successful input, select, textarea and button elements into a query string

 

jQuery 代码:

var data = $(":input").formSerialize();

 


评论 [发表评论]
账号 密码 还没帐号呢,现在注册一个?

免责声明:好库网所展示的信息由买卖双方自行提供,其真实性、准确性和合法性由信息发布人负责。好库网不提供任何保证,并不承担任何法律责任。