How to add name attribute of input field dynamically using Javascript/Jquery
<p>I need one help.I need to add input field name attribute dynamically using Javascript/Jquery. I am each time creating new field by clicking on <code>+</code> button and delete the required field by clicking on <code>-</code> button.I am explaining my code below.</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>function createNew(evt){
  $('#questionshowp1').append('&lt;div class="form-group"&gt;&lt;input name="questions1" id="questions1" class="form-control firstsec" placeholder="Text, Image URL, or LaTeX" value="" type="text"&gt;&lt;div class="secondsec"&gt;&lt;button type="button" class="btn btn-sm btn-success exp-add" style="line-height:12px;" onclick="createNew(this);"&gt;&lt;i class="fa fa-plus" aria-hidden="true"&gt;&lt;/i&gt;&lt;/button&gt;&lt;button type="button" class="btn btn-sm btn-danger exp-minus" style="line-height:12px;" onclick="deleteNew(this)"&gt;&lt;i class="fa fa-minus" aria-hidden="true"&gt;&lt;/i&gt;&lt;/button&gt;&lt;/div&gt;&lt;/div&gt;');
  $(evt).css('display', 'none');
  $(evt).siblings("button.btn-danger").css('display', 'block');
}
function deleteNew(evnt){
  $(evnt).closest(".form-group").remove();
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet"/&gt;
&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
&lt;link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/&gt;
&lt;div class="questionshowp" id="questionshowp1"&gt;
  &lt;div class="form-group"&gt;
    &lt;input name="questions0" id="questions0" class="form-control firstsec" placeholder="Text, Image URL, or LaTeX" value="" type="text"&gt;
    &lt;div class="secondsec"&gt;
      &lt;button type="button" class="btn btn-sm btn-success exp-add" style="line-height:12px;" onclick="createNew(this);"&gt;&lt;i class="fa fa-plus" aria-hidden="true"&gt;&lt;/i&gt;&lt;/button&gt;
      &lt;button type="button" class="btn btn-sm btn-danger exp-minus" style="line-height:12px;display:none;" onclick="deleteNew(this)"&gt;&lt;i class="fa fa-minus" aria-hidden="true"&gt;&lt;/i&gt;&lt;/button&gt;
    &lt;/div&gt;                                                            
  &lt;/div&gt;
&lt;/div&gt;</code></pre>
</div>
</div>
</p>

<p>Here i am creating new field using <code>+</code> button and here i need to increment the name attribute value like <code>questions0,questions1,questions2....</code> this.Suppose user delete any field then also this given order will remain with all field as name attribute value.Please help me.</p>