I
I
ibr_982018-02-25 17:00:01
JavaScript
ibr_98, 2018-02-25 17:00:01

How to get the value of two inputs of the same class?

Hello!
there are two inputs with the same classes, I want to get the value of the second class, but through this code: I get the value of only the first input, I also tried this: but it gives me an error .. how can I get the value of both classes?
$('.input_class').val();
$('.input_class')[1].val();

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kreotech, 2018-02-25
@ibr_98

Like this for example:

var classes = [];
$('.input_class').each(function(index){
  classes[index] = $(this).val();
};

If you only need the second one:
$('.input_class').eq(1).val();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question