title: Javascript code for remove image
body: <p>I want to make this Javascript code to when I click "remove image" link , it remove the image. Please help me.</p>
  
  <p>
     </p>
  
  <pre><code>&lt;script&gt;
  function previewFile(){
  
     var preview = document.querySelector('img'); 
     var file    = document.querySelector('input[type=file]').files[0];
     var reader  = new FileReader();
  
     reader.onloadend = function () {
         preview.src = reader.result;
     }
     if (file) {
         reader.readAsDataURL(file); 
     } else {
         preview.src = "";
     }
  }
  
    previewFile();  
  
  &lt;/script&gt;
  
  &lt;input type="file" onchange="previewFile()"&gt;&lt;br&gt;
  &lt;img src="" height="200" alt="Image preview..."&gt;
  &lt;a href="#"&gt;remove image &lt;/a&gt;
  
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>