Discuss / JavaScript / 总感觉不太优雅

总感觉不太优雅

Topic source

木子_浩子

#1 Created at ... [Delete] [Delete and Lock User]
json = {};
var inputs = $('#test-form :input');
inputs.filter(function(){
   return this.type!='submit';
}).map(function(){
if($(this).get(0).type == "radio"){
    json[this.name] = $("input[type='radio']:checked").val();
}else
   json[this.name] = this.value;
});
json = JSON.stringify(json);

  • 1

Reply