append and appendTo working inconsistently
<p>I'm trying to build a small portfolio and I came up with the script below.
The problem I'm facing is the fact that there are times when append() doesn't seem to work. Same with appendTo() that I also tried.</p>

<p>I mean the script works but the append() function is inconsistant. </p>

<p>Any help will be highly appreciated.</p>

<pre><code>function TMP_folio_logo(action) {

    var logos = Array(
        "logo-1.png",
        "logo-2.png",
        "logo-3.png",
        "logo-4.png",
        "logo-5.png",
        "logo-6.png",
        "logo-7.png",
        "logo-8.png",
        "logo-9.png",
        "logo-10.png"
    );

    if (action == 'undo') {
        $('#fff').stop(true, false);
        $('#fff').empty();
        hd_folioLEFT = 0;
        hd_folioLNUM = 0;
    }

    if (action == 'do') {
        var code = '';
        if (hd_folioLNUM &gt;= logos.length) hd_folioLNUM = 0;
        for (k=hd_folioLNUM; k &lt; (hd_folioLNUM + 4); k++) {
            if (k &lt; logos.length) {
                code += "&lt;div style='left:" + hd_folioLEFT + "px'&gt;&lt;img src='"+ hd_folioPATH + logos[k] +"'&gt;&lt;/div&gt;";
                hd_folioLEFT += 700;
            }
        }

        //$('#fff').append(code);
        $(code).appendTo('#fff');

        $('#fff').delay(4000).animate({left: '-=700'}, 1000, 'swing', function () {
            TMP_folio_logo('do');
        });

        hd_folioLNUM = hd_folioLNUM + 4;    
    }
}
</code></pre>
