json = {}; $('#test-form [type!=submit]').map(function(){ if( (this.type !== "radio") || (this.type === "radio" & this.checked ){ json[this.name] = this.value; } }); json = JSON.stringify(json);
这里特别说一下,Gender两个选项的name均为"gender",如果不针对这一点做一个判定,则后面的<input name="gender"...>的value必然会覆盖前者。
Sign in to make a reply
牛三金
json = {}; $('#test-form [type!=submit]').map(function(){ if( (this.type !== "radio") || (this.type === "radio" & this.checked ){ json[this.name] = this.value; } }); json = JSON.stringify(json);
这里特别说一下,Gender两个选项的name均为"gender",如果不针对这一点做一个判定,则后面的<input name="gender"...>的value必然会覆盖前者。