1
我一直在寻找一个滚动内容框,通过ajax动态加载内容(在我的情况下,缩略图)(而不是将其嵌入到最初的HTML)。我发现这一个:http://webdeveloperplus.com/jquery/create-a-dynamic-scrolling-content-box-using-ajax/,它正是我想要的,除了它垂直滚动。我真的需要一个水平滚动。我只知道足够的JavaScript是危险的,所以我试图修改它的所有调整都没有成功。修改垂直jQuery内容框水平滚动
我喜欢这段代码,因为它只是使用jquery库,而不是额外的js插件。
$('document').ready(function(){
updatestatus();
scrollalert();
});
function updatestatus(){
//Show number of loaded items
var totalItems=$('#content p').length;
$('#status').text('Loaded '+totalItems+' Items');
}
function scrollalert(){
var scrolltop=$('#scrollbox').attr('scrollTop');
var scrollheight=$('#scrollbox').attr('scrollHeight');
var windowheight=$('#scrollbox').attr('clientHeight');
var scrolloffset=20;
if(scrolltop>=(scrollheight-(windowheight+scrolloffset)))
{
//fetch new items
$('#status').text('Loading more items...');
$.get('new-items.html', '', function(newitems){
$('#content').append(newitems);
updatestatus();
});
}
setTimeout('scrollalert();', 1500);
}
是否有任何建议将其修改为水平滚动?