title: HTML button to save div content using javascript
body: <p>I need to save content of div using pure javascript.
  I just edited one fiddle but I can't make it works :(</p>
  
  <p><a href="http://jsfiddle.net/BHeMz/254/" rel="noreferrer">jsfiddle</a></p>
  
  <pre><code>&lt;div id="content"&gt;
  &lt;h1&gt;Hello world&lt;/h1&gt;
  &lt;i&gt;Hi everybody&lt;/i&gt;
  </code></pre>
  
  <p>
  Download</p>
  
  <pre><code>function download(){
      var a = document.body.appendChild(
          document.createElement("a")
      );
      a.download = "export.html";
      a.href = "data:text/html," + document.getElementById("content");
  }
  </code></pre>