<!-- 包含所有文章的容器 --> <div id="content"> <!-- 各文章的容器 --> <div class="post"></div> <div class="post"></div> <div class="post"></div> <div class="post"></div> <div class="post"></div> </div>
<div id="pagination"><?php next_posts_link(__('LOAD MORE')); ?></div>
// 使用 live() 使 js 对通过 Ajax 获得的新内容仍有效
$("#pagination a").live("click", function(){
$(this).addClass("loading").text("LOADING...");
$.ajax({
type: "POST",
url: $(this).attr("href") + "#content",
success: function(data){
result = $(data).find("#content .post");
nextHref = $(data).find("#pagination a").attr("href");
// 渐显新内容
$("#content").append(result.fadeIn(300));
$("#pagination a").removeClass("loading").text("LOAD MORE");
if ( nextHref != undefined ) {
$("#pagination a").attr("href", nextHref);
} else {
// 若没有链接,即为最后一页,则移除导航
$("#pagination").remove();
}
}
});
return false;
});
// 给浏览器窗口绑定 scroll 事件
$(window).bind("scroll",function(){
// 判断窗口的滚动条是否接近页面底部
if( $(document).scrollTop() + $(window).height() > $(document).height() - 10 ) {
$(this).addClass('loading').text('LOADING...');
$.ajax({
type: "POST",
url: $(this).attr("href") + "#content",
success: function(data){
result = $(data).find("#content .post");
nextHref = $(data).find("#pagination a").attr("href");
// 渐显新内容
$("#content").append(result.fadeIn(300));
$("#pagination a").removeClass("loading").text("LOAD MORE");
if ( nextHref != undefined ) {
$("#pagination a").attr("href", nextHref);
} else {
// 若没有链接,即为最后一页,则移除导航
$("#pagination").remove();
}
}
});
}
});
#pagination {padding: 20px 0 0 30px; }
#pagination .nextpostslink {width: 600px; color: #333; text-decoration: none; display: block; padding: 9px 0; text-align: center; font-size: 14px; }
#pagination .nextpostslink:hover {background-color: #cccccc; text-decoration: none; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; }
#pagination .loading {background: url("images/loading.gif") 240px 9px no-repeat; color: #555; }
#pagination .loading:hover {background-color: transparent; cursor: default; }
<nav id="comments-navi">
<?php paginate_comments_links('prev_text=?&next_text=?');?>
</nav>
<?php if( is_single() || is_page() ) {
if( function_exists('get_query_var') ) {
$cpage = intval(get_query_var('cpage'));
$commentPage = intval(get_query_var('comment-page'));
}
if( !empty($cpage) || !empty($commentPage) ) {
echo '<meta name="robots" content="noindex, nofollow" />';
echo "\n";
}
}
?>
<div class="comments">
<h3 id="comments-list-title">Comments</h3>
<!-- 显示正在加载新评论 -->
<div id="loading-comments"><span>Loading...</span></div>
<!-- 评论列表 -->
<ol class="comment_list">
<li>...</li>
<li>...</li>
<li>...</li>
</ol>
<!-- 评论分页导航 -->
<nav id="comments-navi">
<a class="prev page-numbers" href="#">1</a>
...
</nav>
</div>
// 评论分页
$body=(window.opera)?(document.compatMode=="CSS1Compat"?$('html'):$('body')):$('html,body');
// 点击分页导航链接时触发分页
$('#comments-navi a').live('click', function(e){
e.preventDefault();
$.ajax({
type: "GET",
url: $(this).attr('href'),
beforeSend: function(){
$('#comments-navi').remove();
$('.comment_list').remove();
$('#loading-comments').slideDown();
$body.animate({scrollTop: $('#comments-list-title').offset().top - 65}, 800 );
},
dataType: "html",
success: function(out){
result = $(out).find('.comment_list');
nextlink = $(out).find('#comments-navi');
$('#loading-comments').slideUp('fast');
$('#loading-comments').after(result.fadeIn(500));
$('.comment_list').after(nextlink);
}
});
});
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有