序列化问题

serialize()对于未选中的checkbox,radio是获取不到值得。

$.fn.all_serialize = function () { var a = this.serializeArray(); var $radio = $('input[type=radio],input[type=checkbox]', this); var temp = {}; $.each($radio, function () { if (!temp.hasOwnProperty(this.name)) { if ($("input[name='" + this.name + "']:checked").length == 0) { temp[this.name] = ""; a.push({name: this.name, value:0}); } } }); return a; }; $("#form_id").all_serialize();
原文地址:https://www.cnblogs.com/beimingbingpo/p/9759234.html