Discuss
/
JavaScript
/
完整代码 简洁易懂
完整代码 简洁易懂
Topic sourcejson={};
var input = $('#test-form :input[type!=submit]');
input.map(function(){
var value = this.value;
if(this.type === "radio"){
if(this.checked){
value = $(this).parent().get(0).innerText;
json[this.name] = value;
}
}else if(this.name == 'city'){
var children = $(this).find('option');
for(var x in children){
if(children[x].selected){
value = children[x].innerText;
}
}
json[this.name] = value;
}else{
json[this.name] = value;
}
});
json=JSON.stringify(json);
- 1
用户5168869425
so