How to serialize everything but the checkbox elements in jQuery.serialize()?
i开发者_运维问答s there a way to serialize all form elements using serialize() function except the checkboxes?
From the docs:
The .serialize() method can act on a jQuery object that has selected individual form elements, such as
<input>
,<textarea>
, and<select>
.
You could do this:
var s = $('#post-form').find('input, textarea, select')
.not(':checkbox')
.serialize()
You can combine the :input, :not() and :checkbox selectors:
var serialized = $(":input:not(:checkbox)").serialize();
精彩评论