title: Add attribute to the recently added input field in javascript
body: <p>I have the following code which is hidden.</p>
  
  <pre><code>&lt;div id="orderFields" style="display: none;"&gt;
    &lt;table class="table"&gt;
      &lt;tbody id="more-tr"&gt;
        &lt;tr&gt;
          &lt;th style="font-weight: bold"&gt;Offer&lt;/th&gt;
          &lt;td class="col-lg-6 col-md-6 col-sm-12"&gt;
            &lt;input type="text" class="form-control price" id="offer" placeholder="Offer title" value="" novalidate&gt;
          &lt;/td&gt;
          &lt;th style="font-weight: bold"&gt;Image&lt;/th&gt;
          &lt;td class="col-lg-4 col-md-4 col-sm-12"&gt;
            &lt;img src="" style="max-width:40%;max-height:20%" /&gt;
            &lt;input type="file" name="image[]" style="background: transparent;border: transparent"&gt;
          &lt;/td&gt;
          &lt;td class="col-lg-2 col-md-2 col-sm-12"&gt;
            &lt;a href="javascript:void(1);" style="width: 10%;"&gt;
              &lt;span class="voyager-trash remove-this btn-danger" style="padding: 10px; border-radius: 5px;"&gt;&lt;/span&gt;
            &lt;/a&gt;
          &lt;/td&gt;
        &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I have a code to a button that adds the tr field from the hidden field when being clicked.</p>
  
  <pre><code>&lt;div class="col-md-12"&gt;
    &lt;a href="javascript:void(0)" class="btn btn-success btn-xs" id="addMore" style="float: right;"&gt;
      &lt;i class="fa fa-plus"&gt;&lt;/i&gt; &lt;span&gt;Add offer(s)&lt;/span&gt;
    &lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>And the javascript is the following : </p>
  
  <pre><code>$("#addMore").on("click", function() {
    $(".multipleDiv").after($('#orderFields #more-tr').html());
  });
  </code></pre>
  
  <p>The button and tr work perfectly but while submitting a form I am getting data from the div that is hidden. So, I removed the attribute from the div which is hidden. Now, I want to add a name attribute to the input field that is just added after clicking the button. But, again I don't want to add an attribute to the input field of an input tag which is hidden.</p>
  
  <p>How can I achieve that?
  Also, Why am I not getting data coming from the <code>&lt;input type="file" name="image"&gt;</code> which is inside the form tag</p>