0

I can not get my jquery image slider to scroll to the next set of images. It keeps bringing me back to the top of the page when i click on the next arrow. I am not sure if the next row of images is set up properly either. Sorry, but I am new to using jquery.

html

<div id="wrapper2">
<label style="color: #5C5C5C;display: block; font-weight: bold; font-size:16px; text-align: center;margin-bottom:0px;padding-bottom:20px;">Reaching our Goal is proud to partner with great organizations</label>
        <div id="thumbs-wrapper2">
            <div id="thumbs">
                <a class="selected" href="#2"><img src="/assets/images/ROG_p.jpg" /></a>
                <a href="#"><img src="/assets/images/gametime_p.jpg" /></a>
                <a href="#"><img src="/assets/images/american_p.jpg" /></a>
                <a href="#"><img src="/assets/images/bfs_p.jpg" /></a>
                <a href="#"><img src="/assets/images/vballfestival_p.jpg" /></a>
                <a href="#"><img src="/assets/images/yfbca_p.jpg" /></a>
                <a href="#"><img src="/assets/images/sportsattack_p.jpg" /></a>
                <a href="#"><img src="/assets/images/ROG_p.jpg" /></a>
                <a href="#"><img src="/assets/images/gametime_p.jpg" /></a>
                <a href="#"><img src="/assets/images/american_p.jpg" /></a>
                <a href="#"><img src="/assets/images/bfs_p.jpg" /></a>
                <a href="#"><img src="/assets/images/vballfestival_p.jpg" /></a>
                <a href="#"><img src="/assets/images/yfbca_p.jpg" /></a>
                <a href="#"><img src="/assets/images/sportsattack_p.jpg" /></a>
            </div>
            <a id="prev" href="#"></a>
            <a id="next" href="#"></a>
        </div>
</div>

script

$('#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;
    });

css

#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;
}
Anya
  • 21
  • 1
  • 3

2 Answers2

0

the href="#" in your next and prev tags are causing it. remove them or change it to href="javascript:void(0)"

CrayonViolent
  • 32,111
  • 5
  • 56
  • 79
0

Make sure that your javascript is below the html, or surround it using $(function()

$(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;
    });
});

Also, the default behavior of most browsers is to bring you to top of page whenever it sees an # in href, you could tell it to stop that behavior by calling .preventDefault() on the event object passed in by click()

$('#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;
});

EDIT: The issue is caused by a syntax error:

$('#thumbs').carouFredSel({
        responsive: true,
        auto: true,
        prev: '#prev',
        next: '#next',
        items: {
            visible: // here you forgot to assign anything to visible
             min: 2,
             max: 7
Andreas Wong
  • 59,630
  • 19
  • 106
  • 123
  • this helped stop from jumping to the top of the page, but the arrows are still not working to scroll to next set of images...any thoughts? thanks! – Anya May 15 '12 at 01:18
  • Still no good. I tried moving below html as well. Any other thoughts? I appreciate all the help. – Anya May 15 '12 at 01:24
  • @Anya edited my answer :), one thing you might wanna learn is to debug your web app, if you are using chrome, go to your page, press F12, then click on console tab (you'll see syntax error there) – Andreas Wong May 15 '12 at 01:36
  • I've adjusted that too. Still no good. IDK what Im missing but i feel like ive tried everything. – Anya May 15 '12 at 01:48
  • @Anya You are having a lot of 404 and these paths don't seem to be valid (maybe change /path/to/xxx to your real path?): GET https://anya.reachingourgoal.org/path/to/jquery.easing.1.3.js 404 (Not Found) https://anya.reachingourgoal.org/:15GET https://anya.reachingourgoal.org/path/to/jquery-1.4.2.min.js 404 (Not Found) .. etc – Andreas Wong May 15 '12 at 02:00