$(‘#myForm’).submit(function() {
// get all the inputs into an array.
var $inputs = $(‘#myForm :input’);
// not sure if you wanted this, but I thought I'd add it. // get an associative array of just the values. var values = {}; $inputs.each(function() { values[this.name] = $(this).val(); });});这是您可以使用的另一种方法
serializeArray
var values = {};$.each($('#myForm').serializeArray(), function(i, field) { values[field.name] = field.value;});请注意,此代码段将对
<select multiple>元素失败。
看来新的HTML 5表单输入
serializeArray在jQuery1.3版中不起作用。适用于1.4+版本



