我試圖向上或向下滾動div時,將鼠標懸停在各自的箭頭上。我也希望能夠在單擊按鈕時跳下div(想想點擊窗口滾動箭頭而不是拖動滾動條)。jQuery滾動div與scrollTop
的滾動的作品,但跳躍沒有。 scrollTop的()不斷重新調整爲0
下面的代碼:
function startScrollContent()
{
if ($('.haccordion-opened').prev('.header').find('div').attr('title') != 'dontscroll' && $('.haccordion-opened span.arrow').length == 0)
{
$('.haccordion-opened').append('<span class="arrow down" style="position: absolute; bottom: 5px; left: 260px; font-size: 9pt;">▼</span><span class="arrow up" style="position: absolute; bottom: 5px; left: 280px; font-size: 9pt;">▲</span>');
$('.content span.arrow').hover(function()
{
direction = ($(this).hasClass('up')) ? '-=' : '+=';
$('.content .padding').animate({scrollTop: direction + $('.content .padding').css('height')}, 5000);
}, function()
{
$('.content .padding').stop();
});
$('.content span.arrow').click(function()
{
$('.content .padding').stop();
direction = ($(this).hasClass('up')) ? '-' : '+';
alert($('.content .padding').scrollTop());
//$('.content .padding').scrollTop($('.content .padding').scrollTop + direction + 100);
});
}
return;
}
我怎樣才能跳的部分工作?
你嘗試我的代碼嗎?它是如何爲你工作的? – SimonDever 2009-12-09 04:38:02