我有一个标记(show more),当用户单击它时,它会将下10个结果加载到已经存在的结果上。我环顾四周,想让这个搜索引擎优化变得友好,但所有这些讨论都是关于..我如何让我的搜索引擎优化与下一页相关(真正显示更多而不是下一页)
发布于 2015-03-11 00:42:20
与其用ajax加载,为什么不把前10个之后的所有内容都隐藏起来,让下一个标签显示下一个10。
<style>
.hide{
display: none;
}
</style>
<div id='contain'>
<?php
//Not sure what you are loading but this is a dummy loop done in PHP
$i=0;
while($i<101){
//Set the class based on the result. If greater than 10 then hide this result.
$class = ($i<10 ? "result" : "result hide");
echo"<div class='$class'>
<p>MY CONTENT</p>
</div>";
$i++;
}
?>
</div>
<a href='#' id='showMore'>Show 10 More</a>
<script>
$('#showMore').click(function(e){
e.preventDefault();
var i = 0;
$('.hide').each(function(){
if(i<10){
$(this).removeClass('hide');
}
else{
return;
}
i++;
});
});
</script>这是我能想到的解决这个问题的唯一办法。我知道ajax正被用来加快查询速度。
https://stackoverflow.com/questions/28967531
复制相似问题