radio的值使用相同的key覆盖掉,好像很龊。。
var fields = $("#test-form :input"); var checked = $("#test-form :radio:checked") var values = {} fields.each(function () { values[this.name] = $(this).val(); }); values['gender'] = checked.val(); console.log(values); json = JSON.stringify(values);
var fields = $("#test-form :input:not(button)");
否则 button 也进去了,多一个空的 key: value
Sign in to make a reply
光光dane
radio的值使用相同的key覆盖掉,好像很龊。。