babyshandy
1/28/2015 - 8:09 PM

===== Error Checking ===== I know I can get the name/value relationship by using $(#form).serializeArray(); but is there a way to get the wh

===== Error Checking ===== I know I can get the name/value relationship by using $(#form).serializeArray(); but is there a way to get the whole enchilada, type, name and value with one call? http://stackoverflow.com/questions/5666445/jquery-how-to-get-form-element-types-names-and-values Example: http://jsfiddle.net/markcoleman/kkKb8/

var items = $("form :input").map(function(index, elm) {
    return {name: elm.name, type:elm.type, value: $(elm).val()};
});
$.each(items, function(i, d){
    $("body").append("<div>Name:" + d.name + " Type: " +  d.type + " Value: " + d.value + "</div>");
});

$("form :input").each(function(index, elm){
    var $elm = $(elm);
    $("body").append("<h1>Name:" + $(this).attr("name") + " Type: " + $(this).attr("type") + " Value: " + $(this).val() + "</h1>");    
});