Discuss / JavaScript / 二十分钟

二十分钟

Topic source
var obj = {};
var name = $('#test-form :input,#test-form :radio');
name.filter(function(){return this.type !== 'submit'}).each(function(){  
    if (this.type !== 'radio' || this.checked) {
        obj[this.name] = this.value;
    }
});

json = JSON.stringify(obj);

  • 1

Reply