我想向上和向下滚动列表,但它无法正常工作
JSFiddle:Demo
这是javascript代码:
var total = $('ul.item-list li').length;
var $totalImgs = $('ul.item-list li');
var thumbHeight = 0;
for (x=0; x<total; x++) {
thumbHeight = thumbHeight + 41;
};
$('ul.item-list').css({height: thumbHeight + 'px'});
$('#Up').hover(function(e){
$('ul.item-list').stop();
posTop = -parseInt($('ul.item-list').css("margin-top"))
speed = (posTop) * 4;
slideTop = thumbHeight - 50;
$('ul.item-list').animate({"margin-top": "80px"}, 800)},function(){$('ul.item-list').stop();
});
$('#Down').hover(function(e){
posTop = parseInt($('ul.item-list').css("margin-top"))
speed = (thumbHeight + posTop) * 4;
slideTop = thumbHeight - 50;
$('ul.item-list').stop();
$('ul.item-list').animate({"margin-top": -slideTop + "px"}, speed)
},function(){$('ul.item-list').stop();
});
答案 0 :(得分:0)