Selecting a random image from a flickr set and appending it to a div
<p>I've run into a bit of a problem and was hoping to get a little help. I am trying to select a random image from a flickr set and append it to a div to use as a background image. Here is the function:</p>

<pre><code>$.getJSON("http://***", function (data){                                                                                                                                   

    var htmlString = ""; 

    $.each(data.photoset.photo, function(i, item){      

            var bkg = data.photoset.photo[i];
            var randomBkg = Math.floor(Math.random() * bkg.length);

            htmlString += '&lt;img src='+ randomBkg.url_o +' /&gt;';

    return i &lt; 0;   

    });     

    $('#bg').append(htmlString);

 });
</code></pre>

<p>If i replace randomBkg.url_o with bkg.url_o it just returns the first image in the set. using it as i have above appends an image tag with "undefined" as the img src. Any help about where i am misguided would be super appreciated.  </p>
