Fred J. Fred J. - 7 months ago 28
Javascript Question

serializeArray() returning too many elements

Please see the image below, I needed

to return one object and not 4 as the
property gave only one in the selection.

How can I get jQuery serializeArray() to just return all the elements which do not have the class
as stated in the image? Thanks

enter image description here


If requirement is to serialize a single element to an object within and array, you can create an array, and an object; set object property to name of element, set object value to value of element, push object to array.

var arr = [];
var obj = {};
var props = $("form").not(".inactive");
obj[props.attr("name")] = props.val();