Turn a form into an associative array in Jquery
This question already has an answer here:
Here's a dead-simple way:
$.fn.form = function() {
var formData = {};
this.find('[name]').each(function() {
formData[this.name] = this.value;
})
return formData;
};
// use like
var data = $('#editForm').form();
This is totally unsafe and just grabs everything with a name, but it should get you started.
链接地址: http://www.djcxy.com/p/46332.html下一篇: 在Jquery中将表单转换为关联数组