开发者

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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜