title: Check if html img src is empty with javascript
body: <p>I'm trying to learn Javascript and here is an issue I can't resolve.. I have this html tag </p>
  
  <pre><code>  &lt;img id="img1" src="" class="img-thumbnail" style="display:none;" /&gt;
    &lt;input id="addimg" type="button" value="Save URL" onclick='SaveUrl()'/&gt;
  </code></pre>
  
  <p>and with Javascript I want to check if image source is empty here are a Javascript functions:</p>
  
  <pre><code>function SaveUrl() {
      var url = document.getElementById("ImageUrl").value;
      SaveImgUrl(url);
      ClearUrl();
  }
  
  function SaveImgUrl(url) {
          var img = document.getElementById("img1");
          if (img.src.length == 0) {
              img.src = url;
              img.style = "block";
          }
  </code></pre>
  
  <p>Problem is with if statement I mean it returns false when source value is "" I also tried if(img.src == "") but that doesn't help as well. also I know there are simplier solutions provided by jQuery but I want to solve it with simple Javascript without using any frameworks.. please help :)</p>