Copy the value of a dynamic input to another dynamic input

0

Hi, I am new to javascript, but I am working on a dynamic input that is multiplied but how could I make the first dynamic input data be copied to the other inputs ... Thank you very much

Here is a part of my code

    $(document).ready(function() {
          var i = 0;
          $(".origenDato").keyup(function() {
            $(this).parent().parent().find('.destinoDato').val($(this).val());
          });

          $('#CantidadTeo-' + i).change(function() {
            upd_art(i)
          });
          $('#CantidadFab-' + i).change(function() {
            upd_art(i)
          });
          $('#add').click(function() {
            i++;
          });
    });
    
asked by michi_app 04.01.2018 в 17:36
source

1 answer

0

What you could do is iterate for each element that has the class .destinoDato and pass it the value that the keyup event obtained in this way:

      $(document).ready(function(){ 
      var i=0; 
      $(".origenDato").keyup(function () { 

        let valor_a_pasar=$(this).val();
        $('.destinoDato').each(function(){
          $(this).val(valor_a_pasar);
        });

      });

      $('#CantidadTeo-' + i).change(function(){
        upd_art(i)
      });

      $('#CantidadFab-'+ i).change(function(){
        upd_art(i)
      });

      $('#add').click(function(){  
        i++;  
      });
    });
    
answered by 04.01.2018 в 20:37