title: jquery image load check error
body: <p>i'm trying to check if all images are loaded within a container using the below code</p>
  
  <pre><code>$(document).ready(function () {
      $(".slide img").each(function (index) {
          var fakeSrc = $(this).attr('src');
          $("&lt;img/&gt;").attr("src", fakeSrc).css('display', 'none').load(function () {
              alert('loaded');
          }).
          error(function () {
              load_img_Single(fakeSrc);
          });
      });
      function load_img_Single(img) {
          alert(img);
          var ruth;
          $("&lt;img/&gt;").attr("src", img).css('display', 'none').load(function () {
              ruth = 'yeap';
          }).error(function () {
              ruth = 'nope';
          });
          alert(ruth);
      }
  });
  </code></pre>
  
  <p>now as u can see im using a fake container to load the image and check if it has been loaded or not .</p>
  
  <p>im using the .error in the first check of image to see if it was loaded properly or not , if not it executes the function load_img_Single(image) function of mine to load it again.</p>
  
  <p>now in that function again im checking if it was loaded or not . but the problem is the variable 'ruth' is not getting set to anything within that function. its been declared outside but still its coming as 'undefined'.</p>
  
  <p>any insight would be appreciated guys. </p>