新浪微博网页自动底部加载的效果很酷吧?其实这种叫做“无限滚动的翻页技术”,当你页面滑到列表底部时候无需点击就自动加载更多的内容。

其实有很多jQuery的插件都已经实现了这个效果,我们来介绍几个吧!

1、jQuery ScrollPagination

jQuery ScrollPagination plugin 是一个jQuery 实现的支持无限滚动加载数据的插件。

地址:http://andersonferminiano.com/jqueryscrollpagination/

他的demo下载:http://andersonferminiano.com/jqueryscrollpagination/jqueryscrollpagination.zip

实例代码:

$(function(){
$('#content').scrollPagination({
'contentPage': 'democontent.html', // the url you are fetching the results
'contentData': {}, // these are the variables you can pass to the request, for example: children().size() to know which page you are
'scrollTarget': $(window), // who gonna scroll? in this example, the full window
'heightOffset': 10, // it gonna request when scroll is 10 pixels before the page ends
'beforeLoad': function(){ // before load function, you can display a preloader div
$('#loading').fadeIn();
},
'afterLoad': function(elementsLoaded){ // after loading content, you can use this function to animate your new elements
$('#loading').fadeOut();
var i = 0;
$(elementsLoaded).fadeInWithDelay();
if ($('#content').children().size() > 100){ // if more than 100 results already loaded, then stop pagination (only for testing)
$('#nomoreresults').fadeIn();
$('#content').stopScrollPagination();
}
}
});
// code for fade in element by element
$.fn.fadeInWithDelay = function(){
var delay = 0;
return this.each(function(){
$(this).delay(delay).animate({opacity:1}, 200);
delay += 100;
});
};
});

更多相关文章

  1. jquery插件——仿新浪微博限制输入字数的textarea
  2. jQuery基于Canvas的微信运动折线图动态曲线图插件 - wcMotionCha
  3. jQuery Validate 表单验证插件
  4. jQuery图片热点链接添加编辑插件
  5. Jquery验证插件,获取错误字符串
  6. jquery插件ztree的总结
  7. 自定义滚动条插件
  8. 为$ .plugin()用法准备插件而不是$(selector).plugin()
  9. 使用jquery从mysql数据库加载数据

随机推荐

  1. sql2000 第一次执行慢
  2. SQL 在线 UML 设计器 — 使用详解
  3. 我应该如何选择一列与另一列相关的语句?
  4. oralce 解除锁定的表
  5. 文件转换 - .mwb到.sql文件
  6. 返回没有匹配条目的所有日期
  7. SQL2000数据库脱机/只读/紧急模式 修复
  8. Oracle 00932. 00000 - “不一致的数据
  9. java中sql查询条件为中文时,rs.next为fals
  10. 没有必要去指定SqlSessionFactory或SqlSe