title: Download HTML5 as an image
body: <p>How can I download my div as an image? (In JavaScript, Jquery or PHP)</p>
  
  <p>I have a simple HTML code:</p>
  
  <pre><code>&lt;div id="downloadThis"&gt;
    &lt;div style="width: 200px; height: 100px; background: red"&gt;&lt;/div&gt;
    &lt;div style="width: 200px; height: 100px; background: blue"&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;button id="downloader" onClick="download('downloadThis')"&gt;Download&lt;/button&gt;
  </code></pre>
  
  <p>And I want to download it as an image:</p>
  
  <pre><code>&lt;script&gt;
    function download(id){
      document.getElementById(id).downloadAsImage("jpeg");
    }
  &lt;/script&gt;
  </code></pre>