title: Add list elements dynamically to ul element
body: <p>I would like to add more li elements, like the first one, dynamically, i.e. by pressing a button. Here is a not working example on <a href="https://jsfiddle.net/danielecordano/o93ghfc9/" rel="nofollow">jsfiddle</a> </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>document.onload = init;
  function init(){
    document.getElementById('add').onclick = add;
  }
  function add(){
    var el = document.getElementById('list');
    var node = document.createElement("li");
    var link = document.createElement("link");
    link.setAttribute('href', 'www.google.it');
    link.setAttribute('name', 'link');
    node.appendChild(link);
    el.appendChild(node);
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;ul id="list"&gt;
    &lt;li&gt;
      &lt;a href="www.google.it"&gt;link&lt;/a&gt;
    &lt;/li&gt;
  &lt;/ul&gt;
  &lt;button id="add"&gt;Add link&lt;/button&gt;</code></pre>
  </div>
  </div>
  </p>