Reputation: 113
I am making a simple slideshow from a tutorial: http://line25.com/tutorials/how-to-build-a-sliding-feature-slideshow-with-jquery
I got most of it working, except when i click on the nav buttons, it stays on the same first button, and the screen goes down to the top of the image.
LIVE DEMO: http://epicureancateringaz.com/New/new1
// JavaScript Document
$(document).ready(function() {
$("#slideshow").css("overflow", "hidden");
$("#slideshow-nav").css("visability", "visable");
$("#slideshow-nav a[href=#photos1]").addClass("active");
$("#slideshow-nav").localScroll({
target:'#slideshow', axis: 'x'
});
$("#slideshow-nav a").click(function(){
$("#slideshow-nav a").removeClass("active");
$(this).addClass("active");
});
});
//css
#slideshow{
width:1000px;
height:320px;
margin:auto;
box-shadow:0px 0px 80px #000;
-moz-box-shadow:0px 0px 80px #000;
-webkit-box-shadow:0px 0px 80px #000;
}
#slideshow ul{
width:4000px;
list-style:none;
}
#slideshow ul li{
float:left;
}
#slideshow-nav{
width:250px;
margin:0 auto 200px auto;
}
#slideshow-nav ul{
list-style:none;
}
#slideshow-nav ul li{
float:left;
}
#slideshow-nav ul li a{
display:block;
width:30px;
height:30px;
float:left;
margin:0 10px;
background-color:#fff;
border-radius:30px;
-moz-border-radius:30px;
-webkit-border-radius:30px;
box-shadow:0px 0px 30px #000;
-moz-box-shadow:0px 0px 30px #000;
-webkit-box-shadow:0px 0px 30px #000;
}
#slideshow-nav ul li a:hover, #slideshow-nav ul li a.active{
background-color:#a89d8a;
}
//html
<div id="slideshow">
<ul>
<li id="photos1"><a href=""><img src="images/photos/1.jpg" alt="img 1" /></a></li>
<li id="photos2"><a href=""><img src="images/photos/2.jpg" alt="img 2" /></a></li>
<li id="photos3"><a href=""><img src="images/photos/3.jpg" alt="img 3" /></a></li>
<li id="photos4"><a href=""><img src="images/photos/4.jpg" alt="img 4" /></a></li>
</ul>
</div>
<div id="slideshow-nav">
<ul>
<li><a href="#photos1"></a></li>
<li><a href="#photos2"></a></li>
<li><a href="#photos3"></a></li>
<li><a href="#photos4"></a></li>
</ul>
</div>
Upvotes: 0
Views: 261
Reputation: 36
First thing is that you don't have localScroll plugin on your page.
<script src="js/jQuery.LocalScroll.js"></script>
by tutorial you supposed to have it.
And then change the event handler of $("#slideshow-nav a") to
$("#slideshow-nav a").click(function(e){
e.preventDefault();
$("#slideshow-nav a").removeClass("active");
$(this).addClass("active");
});
so screen will not go down.
Upvotes: 0
Reputation: 1379
I see error in console:
Uncaught TypeError: Object [object Object] has no method 'localScroll' script.js:7
You forgot to include jQuery.LocalScroll
download this library, put it to your js folder and insert this into head tag
<script src="js/jQuery.LocalScroll.js"></script>
Upvotes: 1