基本上,我在我的WordPress博客上实现了无限滚动(.com),下面是代码:
HTML格式
<div id="photos" class="display-fix">
<?php while ( have_posts() ) : the_post(); ?>
<img src="<?php $url = get_post_thumbnail_id(); $url = wp_get_attachment_image_src($url,'medium'); $url = $url[0]; echo $url; ?>">
<?php endwhile; ?>
</div>
<div id="pagination" class="clear right">
<?php if(function_exists('wpex_pagination')) { wpex_pagination(); } ?>
</div>
JS文件
$('#photos').infinitescroll({
navSelector : ".next:last", // selector for the paged navigation (it will be hidden)
nextSelector : "a.next:last", // selector for the NEXT link (to page 2)
itemSelector : "#photos img", // selector for all items you'll retrieve
loading: {
finished: undefined,
finishedMsg: '',
img: "<?php echo get_template_directory_uri(); ?>/images/preloader.gif",
msg: null,
msgText: '',
selector: null,
speed: 'slow',
start: undefined
}
});
$('#photos img').hover(function(){
alert('Works');
});
CSS格式
#photos {
width: 100%;
padding: 20px;
}
#photos img {
width: 504px;
margin: 3px;
float: left;
}
#infscr-loading {
position: absolute;
width: 100px;
height: 100px;
left: 50%;
margin-left: -50px;
bottom: 10px;
}
#infscr-loading img {
width: 100px;
height: 100px;
}
当我向下滚动时,当图像弹出时,悬停警告不起作用,它只在显示的第一个图像上起作用!弹出的那些不起作用。
为什么?我正在使用
$(document).ready(function() {
我还要用别的吗?