Why isn't my `load` function getting called?
<p>I'm trying to preload certain images that I have decorated with an attribute and I'm wondering if you guys can help me figure out what's going wrong here. I have</p>

<pre><code>          var barlen = $('#SSWEprogressbar').width(),
              $elems = $('[data-srcurl]'),
                   n = $elems.length;
          for ( var k = 0; k &lt; n; ++k )
          {
              var $elem = $($elems[k]);
              var img = new Image(),
                  url = $elem.attr('data-srcurl');

              $(img).load(function(){
                 console.log("we're here");//TEST
                 $('#SSWEloaderfront').attr('src',url);

                 $('#SSWEloadprogress').width(k/n*barlen + "px");
              });
              var srctgt = $elem.attr('data-srctgt');
              if ( srctgt == "srcattr" )
              {
                $elem.attr('src',url);
              }
              else if ( srctgt == "bgimg" )
              {
                $elem.css('background-image',url);
              }
          }
</code></pre>

<p>and then</p>

<pre><code>console.log("we're here");//TEST
</code></pre>

<p>isn't being invoked. Any ideas?</p>