我正在使用infinite scrolling作为搜索结果页面。我遇到的问题是,当您搜索“Android”之类的内容时,在第一页上看到的结果中会突出显示该单词,但如果您滚动到页面底部并查看更多结果,那么条目没有突出显示搜索词。 因此,加载无限滚动的页面没有突出显示的搜索项。突出显示的脚本是here
$(document).ready(function() {
jQuery.ias({
container : '.articles',
item: '.article',
pagination: '#pagination',
next: '.next_page',
triggerPageThreshold: 1003,
loader: '<img src="loader.gif"/>'
});
});
执行突出显示:
。在firebug中,当我运行脚本时它运行正常。如何在无限滚动内部实现,以便用它触发?$( 'P')突出( '机器人');
答案 0 :(得分:0)
这样做
$(document).scroll(function(){
var el = $('body');
var top = $(el).offset().top - $(document).scrollTop();
if (top < 5){
var term = $('#q').val();
$('p').highlight(term);
}
});