title: JavaScript: add input element to current div
body: <p>I have a javascript function which adds a div with three inputs to the page and a link to add more inputs to the same div (Imagine that user doesn't know how many fields there will be so he can add them dynamically). </p>
  
  <pre><code>var div=document.createElement("div");
  div.innerHTML='&lt;input type="text" name="question" /&gt;&lt;br&gt;&lt;br&gt;'+
                '&lt;input type="text" name="input1"/&gt;&lt;br /&gt;'+
                '&lt;input type="text" name="input2"/&gt;&lt;br /&gt;'+
                '&lt;a href="javascript:addInput()"&gt;Add input field&lt;/a&gt;';
  
  var parent_div=document.getElementById('dinamicni_div');
  parent_div.appendChild(div);
  </code></pre>
  
  <p>How could I now implement this addInput() function to add an input below the last input (currently <em>input2</em>) in the same div (but above the link)?</p>
  
  <p><em>Just to make clear - I have two JS functions to generate content dynamically: addDiv(), which you can see above shortened out; and addInput() which I would like to implement and it should add one input in the current div, where the link was clicked.</em></p>