我要滾動列表向上和向下,但它不工作如何滾動列表向上和向下的鼠標事件
的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();
});
什麼具體不工作?你有什麼錯誤嗎? – Andy
請使一個正確的小提琴和發佈它 – Zword
所以你需要所有列表上下滾動只有在淺灰色部分 –