JavaScript
Article
By Sam Deering

jQuery output all input values in a form

By Sam Deering

Simple jQuery code snippet to output all the values of input elements within a form with a specific id. You can get both the attribute name and value this way.

console.log("----------------------------------");
$('#form-id > input,#form-id > textarea').each(function(index) {
    console.log($(this).attr('name') + " = " + $(this).val());
});
console.log("----------------------------------");

Note: the console.log() commands are just for use with firebug.

--ADVERTISEMENT--

Recommended
Sponsors
The most important and interesting stories in tech. Straight to your inbox, daily. Get Versioning.
Login or Create Account to Comment
Login Create Account