TAKE DATA FROM FORM JS

Asked

Viewed 287 times

1

So I wanted to do the following has a form which has several input fields, so I wanted to do the following loop or something similar to get the values of the fields using jquery or js (pure).

I’d like to know a way to do that

  • Tried to do something? What do you know about Javascript?

1 answer

2


Jquery

// pega todos os input
var $inputs = $('form :input');

var values = {};
// percorre os inputs 
$inputs.each(function() {
    var name = this.name; // nome do input
    var value = $(this).val(); // valor do input
});

Browser other questions tagged

You are not signed in. Login or sign up in order to post.