jQuery无限滚动

时间:2013-10-04 16:19:44

标签: javascript jquery web-applications

我尝试用jQuery实现基本的无限滚动:

<!DOCTYPE html>
<html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
</head>

<body>


    <div>
        <div id="tweets">
            <script>
                for(var j=0; j<=99; j++)
                    document.write(j+'<br/>');
            </script>
        </div>
    </div>

    <script>
        var start = 0;
        var count = 100;

        $(window).scroll(function()
        {   
            if($(window).scrollTop() == $(document).height() - $(window).height())
            {
                start += count;
                for(var i=start; i<=start+count; i++)
                    $('div#tweets').append(i+'<br/>');
            }
        });
    </script>

</body>

但它不起作用?可能是什么问题?原始来源为here

0 个答案:

没有答案