var obj = {}; $('#test-form :input:not(button)') .map(function() { if(this.name==='gender' && !this.checked) { return; } obj[this.name] = this.value; }); json = JSON.stringify(obj);
这应该是满分吧? 感谢!
Sign in to make a reply
_mundane
var obj = {}; $('#test-form :input:not(button)') .map(function() { if(this.name==='gender' && !this.checked) { return;
} obj[this.name] = this.value; }); json = JSON.stringify(obj);