title: How to remove image preview when cleared?
body: <p>I have a program where a selected image is previewed. Here is the code I use.</p>
  
  <p><strong>Javascript</strong></p>
  
  <pre><code>function readURL(input) {
  
          if (input.files &amp;&amp; input.files[0]) {
              var reader = new FileReader();
  
              reader.onload = function (e) {
                  $('#preview').attr('src', e.target.result);
              }
  
              reader.readAsDataURL(input.files[0]);
          }
      }
  
      $("#uploadphoto").change(function(){
          readURL(this);
          $('#preview').show();
      }); 
  </code></pre>
  
  <p>But when I remove it with this:</p>
  
  <pre><code>$('#preview').on("click", function () {
       $('#uploadphoto').replaceWith( selected_photo = $('#uploadphoto').clone( true ) );
       $('#preview').attr('src', '');
  });
  </code></pre>
  
  <p>The photo still is displayed. When I submit the page the photo is not submitted, which I wanted, but how do I get rid of the preview image? <code>$('#preview').attr('src', '');</code> didn't seem to work...?</p>