Jquery 图像滑块…下一个和上一个按钮不工作

Jquery 图像滑块…下一个和上一个按钮不工作,jquery,slider,jcarousel,Jquery,Slider,Jcarousel,我无法让jquery图像滑块滚动到下一组图像。当我点击下一个箭头时,它总是把我带回到页面顶部。我不确定下一行图像是否设置正确。对不起,我对使用jquery还不熟悉 html css 您的next和prev标记中的href=“#”导致了该问题。删除它们或将其更改为href=“javascript:void(0)”确保您的javascript位于html下方,或使用$(function() 此外,大多数浏览器的默认行为是,每当它在href中看到#时,都会将您带到页面顶部,您可以通过调用click()

我无法让jquery图像滑块滚动到下一组图像。当我点击下一个箭头时,它总是把我带回到页面顶部。我不确定下一行图像是否设置正确。对不起,我对使用jquery还不熟悉

html

css


您的next和prev标记中的
href=“#”
导致了该问题。删除它们或将其更改为
href=“javascript:void(0)”

确保您的javascript位于html下方,或使用
$(function()

此外,大多数浏览器的默认行为是,每当它在
href
中看到
#
时,都会将您带到页面顶部,您可以通过调用
click()传入的
事件
对象上的
.preventDefault()
告诉它停止该行为

编辑:问题是由语法错误引起的:

$('#thumbs').carouFredSel({
        responsive: true,
        auto: true,
        prev: '#prev',
        next: '#next',
        items: {
            visible: // here you forgot to assign anything to visible
             min: 2,
             max: 7

这有助于阻止跳转到页面顶部,但箭头仍然无法滚动到下一组图像…有想法吗?谢谢!仍然不好。我也尝试过在html下方移动。还有其他想法吗?我感谢所有帮助。@Anya编辑了我的答案:),您可能想学习的一件事是调试您的web应用程序,如果您使用的是chrome,请转到您的页面,按F12键,然后单击console选项卡(您将在那里看到语法错误),我也对其进行了调整。还是不行。IDK我错过了什么,但我觉得我已经尝试了一切。@Anya你有很多404,但这些路径似乎无效(可能将/path/to/xxx更改为你的真实路径?):获取404(未找到)404(未找到)。。等
$('#thumbs').carouFredSel({
        responsive: true,
        auto: true,
        prev: '#prev',
        next: '#next',
        items: {
            visible: 
             min: 2,
             max: 4
            },
            width: 150,
            height: '25%'
    });
    });

    $('#thumbs a').click(function() {
        $('#carousel').trigger('slideTo', '#'+this.href.split('#').pop());
        $('#thumbs a').removeClass('selected');
        $(this).addClass('selected');
        return false;
    });
#wrapper2 {
    position: relative;
    width: 100%;
    top: 50px;
}
#carousel, #thumbs {
    overflow: hidden;
    height: 62px;
}

#carousel span, #carousel img,
#thumbs a, #thumbs img  {
    display: block;
    float: left;
}
#carousel span, #carousel a,
#thumbs span, #thumbs a {
    position: relative;
}
#carousel img,
#thumbs img {
    border: medium none;
    height: 58px;
    left: 0;
    position: relative;
    top: 0;
    width: 100px;
}
#carousel img.glare,
#thumbs img.glare {
    width: 102%;
    height: auto;
}

#thumbs-wrapper2 {
    padding: 20px 40px;
    position: relative;
    width: 73%;
    margin: -18px 0 0 162px;
    height: 90px;
}
#thumbs a {
    height: 58px;
    margin: 0 10px;
    overflow: hidden;
    width: 100px;
    border: 2px solid #899;
    border-radius: 10px;
    -webkit-transition: border-color .5s;
    -moz-transition: border-color .5s;
    -ms-transition: border-color .5s;
    transition: border-color .5s;

}
#thumbs a:hover, #thumbs a.selected {
    border-color: #566;
}

#prev, #next {
    display: block;
    height: 50px;
    margin: -38px 0 0 -35px;
    position: absolute;
    top: 50%;
    width: 50px;
}
#prev {
    background-image: url(/assets/images/left.jpg);
    background-position: 0 0;
    left: 10px;
}
#next {
    background-image: url(/assets/images/right.jpg);
    background-position: -50px 0;
    right: 33px;
}           
#prev:hover { 
    background-position: 0 0;               
}
#next:hover {
    background-position: -50px 0;               
}

#prev.disabled, #next.disabled {
    display: none !important;
}
$(function() {
   $('#thumbs').carouFredSel({
        responsive: true,
        auto: true,
        prev: '#prev',
        next: '#next',
        items: {
            visible: 
             min: 2,
             max: 4
            },
            width: 150,
            height: '25%'
    });
    });

    $('#thumbs a').click(function() {
        $('#carousel').trigger('slideTo', '#'+this.href.split('#').pop());
        $('#thumbs a').removeClass('selected');
        $(this).addClass('selected');
        return false;
    });
});
$('#thumbs a').click(function(e) {
    e.preventDefault(); // add this
    $('#carousel').trigger('slideTo', '#'+this.href.split('#').pop());
    $('#thumbs a').removeClass('selected');
    $(this).addClass('selected');
    return false;
});
$('#thumbs').carouFredSel({
        responsive: true,
        auto: true,
        prev: '#prev',
        next: '#next',
        items: {
            visible: // here you forgot to assign anything to visible
             min: 2,
             max: 7