1

您好有两个导航箭头 Prev 和 Next 的导航菜单。这适用于除 Chrome 之外的所有浏览器(Firefox、IE、Opera、Safari)。按下按钮时甚至不会收到错误消息。

有人可以看看按钮的代码。我错过了什么吗?

谢谢!

function scroll(direction) {        
    var scroll, i, positions = [], here = $(window).scrollTop(), collection = $('.box'), duration = 750, easing = "easeOutExpo";

    collection.each(function() {
        positions.push(parseInt($(this).offset()['top'], 10));
    });

    for( i = 0; i < positions.length; i++ ) {
        if( direction == 'next' && positions[i] > here ) { 
            scroll = collection.get(i);
            break;
        }
        if( direction == 'prev' && i > 0 && positions[i] >= here ) { 
            scroll = collection.get(i-1); 
            break;
        }
    }

    if(scroll) {
        $.scrollTo( scroll, { duration: duration, easing: easing });
    }

    return false;
}

$("a#prev, a#next").click(function() {
    return scroll($(this).prop( 'id' ));
});
4

1 回答 1

0

当我将 jQuery 版本从 1.8.2 降级到 1.6.2 时,这个问题得到了解决

于 2012-11-21T12:39:05.440 回答