开发者

How to serialize everything but the checkbox elements in jQuery.serialize()?

开发者 https://www.devze.com 2023-03-18 09:16 出处:网络
i开发者_运维问答s there a way to serialize all form elements using serialize() function except the checkboxes?From the docs:

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

精彩评论

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