Discuss / JavaScript / Benjamin提交作业

Benjamin提交作业

Topic source
json = {};
// 利用和表单元素相关的特殊选择器
// 理解filter和map的机制
$('#test-form :input').not('button').filter(function(){
    //console.log(this.type);
    return this.type !== 'radio' || this.checked;
}).map(function(){
    json[this.name] = this.value;
    return true;
});

json = JSON.stringify(json);

  • 1

Reply