title: How to set value in dynamically added rows form using jquery?
body: <p>I have a form in php with dynamically added rows (after clicking button the row is added). I want to fill the field with value "xx" and i want to do it in jquery.</p>
  
  <p>This loop  create the dynamically added rows in jquery. I want to fill added fields with value "xx":</p>
  
  <pre><code>while($personsArrayLength&gt;2){
          echo '
              &lt;script&gt;
              $(document).ready(function(){
                  var i = 2;
                  var rowTemplate2 = jQuery.format($("#template2").html());
  
                  rowTemplate2.value = "xx";
                  addRow2();
  
                  function addRow2(){
                      var ii = i++;
                      $("#app_here2").append(rowTemplate2(ii));
                      $("#delete_" + ii).click(function(){
                          $("#row_" + ii).remove();
                      });
                  }
              });
          &lt;/script&gt;
      ';
  </code></pre>
  
  <p>Here is html for that:</p>
  
  <pre><code>function addRows2(){
  
      global $personsError_css;
      $personsArray = $_POST['persons'];
      JB_var_dump($_POST['whichRow']);
          $html = '&lt;table id="template2" align="right" style="display:none; "&gt;
              &lt;tr id="row_{0}"&gt;
                  &lt;td&gt;&lt;input type="text" size="52" id="persons" name="persons[]" maxlength="100"&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;img src="/../_img/row_del.png" id="delete_{0}" alt="usun"&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
          &lt;table id="list2" style="margin-left:200px;"&gt;
              &lt;thead &gt;
                  &lt;tr&gt;
                      &lt;th&gt;&lt;/th&gt;
                      &lt;th&gt;&lt;/th&gt;
                  &lt;/tr&gt;
              &lt;/thead&gt;
  
              &lt;tbody&gt;
                  &lt;tr&gt;
                      &lt;td&gt;&lt;input type="text" size="52" name="persons[]" maxlength="100" style="'.$personsError_css.';" value="'.$personsArray[1].'"&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;/td&gt;
                  &lt;/tr&gt;
  
                  &lt;tr&gt;
                      &lt;td colspan="2" id="app_here2"&gt;&lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/tbody&gt;
          &lt;/table&gt;';
          return $html;
  } 
  </code></pre>
  
  <p>This is properly filled form<br>
      <img src="https://i.stack.imgur.com/NkgD5.gif" alt="enter image description here"></p>
  
  <p>In this epty fields I want to add values "xx"
  <img src="https://i.stack.imgur.com/ScLnJ.gif" alt="enter image description here"></p>
  
  <p>Sorry for my english. </p>
  
  <p>How can i set values in added rows? What i should change in my code?
  Thanks for help. </p>