这次给大家带来如何实现滚动条滑到底部时自动加载更多内容,实现滚动条滑到底部时自动加载更多内容的注意事项有哪些,下面就是实战案例,一起来看一下。
本文实例讲述了jQuery实现滚动到底部时自动加载更多的方法。分享给大家供大家参考,具体如下:
这里利用AJAX,实现滚动到底加载数据功能:
nbsp;html> <meta> <title></title> <script></script> <script> $(function () { AddSth(); }); $(function () { $(".main").unbind("scroll").bind("scroll", function (e) { var sum = this.scrollHeight; if (sum <= $(this).scrollTop() + $(this).height()) { AddSth(); } }); }); function AddSth() { $.ajax({ type: 'POST', url: "index.aspx/ReturnSth", dataType: "json", contentType: "application/json; charset=utf-8", //data: "", success: function (data) { json = $.parseJSON(data.d); for (var i in json) { var tbBody = "<ul><li>" + json[i].sth + ""; $(".main").append(tbBody); } $(".main").append("<hr />"); } }); } </script>
相信看了本文案例你已经掌握了方法,更多精彩请关注php中文网其它相关文章!
推荐阅读:
以上就是如何实现滚动条滑到底部时自动加载更多内容的详细内容,更多请关注php中文网其它相关文章!
Copyright 2014-2024 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号