.Each in two elements with values in different variables

0

I have two elements, EndTime and StartTime that are two inputs and both have the class time.

With each one you need to have the value of the two separated into variables.

$('.hora').each(function (){
  var horaFinal = $('.horaFinal').val();
  var horaInicio = $('.horaInicio').val();
})

But when I do this my inputs are empty.

    
asked by anonymous 21.06.2017 / 15:34

1 answer

2

If you know that there are only two inputs one for the beginning and one for the end you do not have to go through with each

Just get the first and last element with class hora :

var horaInicial = $('.hora').first().val();
var horaFinal = $('.hora').last().val();
    
21.06.2017 / 16:03