Create a jQuery slideshow that enables you to click through each slide when JavaScript is disabled, without having to display all slides one under the other.
Build an Auto-Scrolling Slideshow That Works With and Without JavaScript
May 12th in JavaScript & AJAX by Jenna SmithIntroduction
There are several tutorials that walk people through how to create a jQuery slideshow, but there aren't many that focus on making it function without JavaScript. This is because most people believe it isn't possible but I am going to explain an exceedingly simple method that shows it is indeed possible. You'll soon be kicking yourself and asking "How did I not think of that?"…
In this tutorial I will cover the following:
- Creating a functional tabbed slideshow without JavaScript
- Downloading the jQuery Cycle plugin
- Progressively enhancing the slideshow with the use of the jQuery Cycle plugin
Step 1: Writing the markup
First things first, we need to write the markup that our slideshow will use. So let's jump straight in and code it up:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Tabbed jQuery slideshow</title>
<link rel="stylesheet" href="css/slideshow.css" type="text/css" media="screen" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
</head>
<body>
<div id="slideshow">
<div class="slides">
<ul>
<li>
<h2>Slide one</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Donec pretium arcu non velit. Phasellus adipiscing auctor
lorem. Curabitur in urna ut purus consequat sollicitudin.
Phasellus ut diam. Cras magna libero, tempor id, venenatis
sit amet, venenatis et, dui.
</p>
</li>
<li>
<h2>Slide two</h2>
<p>
Nam ac nibh sit amet augue ultricies sagittis. Donec sit
amet nunc. Vivamus lacinia, nisi ac tincidunt commodo, purus
nisi condimentum urna, sit amet molestie odio dolor non lectus.
Cum sociis natoque penatibus et magnis dis parturient montes,
nascetur ridiculus mus.
</p>
</li>
<li>
<h2>Slide three</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Suspendisse adipiscing dui a nibh. Integer tristique lorem
vitae massa. Etiam dapibus, eros sit amet euismod semper,
felis erat congue lacus, sed aliquam metus libero sed elit.
</p>
</li>
</ul>
</div>
<ul class="slides-nav">
<li><a href="#">Slide one</a></li>
<li><a href="#">Slide two</a></li>
<li><a href="#">Slide three</a></li>
</ul>
</div>
</body>
</html>
This isn't quite complete yet but as a general rule of thumb, we should always start with the bare minimum and enhance/add to it when necessary.
Step 2: Add some CSS
We're not going to be creating the most beautiful slideshow today as I just want to demonstrate the functionality more than anything. The following styles will set up our slideshow ready for action:
/* ---------------------------------------------------- */
/* GLOBAL
/* ---------------------------------------------------- */
html {
font-size: 76%;}
body {
font-family: arial, helvetica, sans-serif;
line-height: 1.4em;
font-size: 1.2em;
padding: 5%;}
/* ---------------------------------------------------- */
/* SLIDESHOW
/* ---------------------------------------------------- */
#slideshow {
width: 960px;
background-color: #eee;
border: 1px solid #ddd;}
#slideshow ul {
margin: 0;
padding: 0;
list-style-type: none;
height: 1%; /* IE fix */}
#slideshow ul:after {
content: ".";
clear: both;
display: block;
height: 0;
visibility: hidden;}
/* ---------------------------------------------------- */
/* SLIDESHOW > SLIDES
/* ---------------------------------------------------- */
#slideshow .slides {
overflow: hidden;
width: 960px;}
#slideshow .slides ul {
/* total width of all slides -
960px multiplied by 3 in this case */
width: 2880px;}
#slideshow .slides li {
width: 920px;
float: left;
padding: 20px;}
#slideshow .slides h2 {
margin-top: 0;}
/* ---------------------------------------------------- */
/* SLIDESHOW > NAVIGATION
/* ---------------------------------------------------- */
#slideshow .slides-nav {
background-color: #ddd;
border-top: 2px solid #ccc;}
#slideshow .slides-nav li {
float: left;}
#slideshow .slides-nav li a {
display: block;
padding: 15px 20px;
outline: none;}
Add these styles to a slideshow.css stylesheet in a CSS directory within the root. You should now see something similar to this:

Step 3: Making it function without JavaScript
Some of you are probably wondering how on earth this is going to work by now so I won't make you wait any longer.
All we need to do is give each of our slides an ID and reference that ID in the href attribute of the appropriate navigation item. It's that simple.
Your new markup should look as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Tabbed jQuery slideshow</title>
<link rel="stylesheet" href="css/slideshow.css" type="text/css" media="screen" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
</head>
<body>
<div id="slideshow">
<div class="slides">
<ul>
<li id="slide-one">
<h2>Slide one</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Donec pretium arcu non velit. Phasellus adipiscing auctor
lorem. Curabitur in urna ut purus consequat sollicitudin.
Phasellus ut diam. Cras magna libero, tempor id, venenatis
sit amet, venenatis et, dui.
</p>
</li>
<li id="slide-two">
<h2>Slide two</h2>
<p>
Nam ac nibh sit amet augue ultricies sagittis. Donec sit
amet nunc. Vivamus lacinia, nisi ac tincidunt commodo, purus
nisi condimentum urna, sit amet molestie odio dolor non lectus.
Cum sociis natoque penatibus et magnis dis parturient montes,
nascetur ridiculus mus.
</p>
</li>
<li id="slide-three">
<h2>Slide three</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Suspendisse adipiscing dui a nibh. Integer tristique lorem
vitae massa. Etiam dapibus, eros sit amet euismod semper,
felis erat congue lacus, sed aliquam metus libero sed elit.
</p>
</li>
</ul>
</div>
<ul class="slides-nav">
<li><a href="#slide-one">Slide one</a></li>
<li><a href="#slide-two">Slide two</a></li>
<li><a href="#slide-three">Slide three</a></li>
</ul>
</div>
</body>
</html>
Now test out your new code by clicking each tab… How cool is that?
This is by no means an undiscovered technique. People are already using it on sites you have probably used without realising, such as the Coda website.
Step 4: Adding Some Animation
Right well, that was fun! Now it's time to add some funky sliding animations to our slideshow.
You'll need to download the minified jQuery Cycle plugin that includes all transitions and save it as jquery.cycle.js within a 'js' directory in your project root. Then add the following to your <head> below the jquery library script tag.
<script type="text/javascript" src="js/jquery.cycle.js"></script> <script type="text/javascript" src="js/slideshow.js"></script>
We'll now create the slideshow.js file mentioned above and save it in the 'js' directory with the following code:
$slideshow = {
context: false,
tabs: false,
timeout: 1000, // time before next slide appears (in ms)
slideSpeed: 1000, // time it takes to slide in each slide (in ms)
tabSpeed: 300, // time it takes to slide in each slide (in ms) when clicking through tabs
fx: 'scrollLeft', // the slide effect to use
init: function() {
// set the context to help speed up selectors/improve performance
this.context = $('#slideshow');
// set tabs to current hard coded navigation items
this.tabs = $('ul.slides-nav li', this.context);
// remove hard coded navigation items from DOM
// because they aren't hooked up to jQuery cycle
this.tabs.remove();
// prepare slideshow and jQuery cycle tabs
this.prepareSlideshow();
},
prepareSlideshow: function() {
// initialise the jquery cycle plugin -
// for information on the options set below go to:
// http://malsup.com/jquery/cycle/options.html
$("div.slides > ul", $slideshow.context).cycle({
fx: $slideshow.fx,
timeout: $slideshow.timeout,
speed: $slideshow.slideSpeed,
fastOnEvent: $slideshow.tabSpeed,
pager: $("ul.slides-nav", $slideshow.context),
pagerAnchorBuilder: $slideshow.prepareTabs,
before: $slideshow.activateTab,
pauseOnPagerHover: true,
pause: true
});
},
prepareTabs: function(i, slide) {
// return markup from hardcoded tabs for use as jQuery cycle tabs
// (attaches necessary jQuery cycle events to tabs)
return $slideshow.tabs.eq(i);
},
activateTab: function(currentSlide, nextSlide) {
// get the active tab
var activeTab = $('a[href="#' + nextSlide.id + '"]', $slideshow.context);
// if there is an active tab
if(activeTab.length) {
// remove active styling from all other tabs
$slideshow.tabs.removeClass('on');
// add active styling to active button
activeTab.parent().addClass('on');
}
}
};
$(function() {
// initialise the slideshow when the DOM is ready
$slideshow.init();
});
NOTE: To keep this tutorial short, I won't explain everything in this new javascript file but if you have any questions, feel free to ask in the comments below and I'll do my best help you out =)
Open your updated slideshow in a browser (ensuring there is no #slide-{num}) on the end of your URL) and wait… See it sliding?… Great! Now you can click the tabs and watch it slide a little quicker.
Step 5: Highlighting the active tab
So, we've got it working but what's this $slideshow.activateTab() method that we added? Well it isn't entirely necessary since the jQuery Cycle plugin already adds an .activeSlide class to the active navigation link for you, however, I like to give a little more control over my navigations so this method just adds an .on class to the parent <li> of the active link.
With this in place, you can add the following CSS to the end of our slideshow.css stylesheet to highlight the active tab:
#slideshow .slides-nav li.on,
#slideshow .slides-nav li.on a {
background-color: #eee;}
#slideshow .slides-nav li.on a {
position: relative;
top: -4px;}
When you preview, you'll probably notice that the first tab isn't highlighted on page load…this is easy to fix…just use jQuery to add a .js class to the <body> tag as shown below:
$(function() {
// add a 'js' class to the body
$('body').addClass('js');
// initialise the slideshow when the DOM is ready
$slideshow.init();
});
Then prepend the CSS we just added with the new .js class:
.js #slideshow .slides-nav li.on,
.js #slideshow .slides-nav li.on a {
background-color: #eee;}
.js #slideshow .slides-nav li.on a {
position: relative;
top: -4px;}
This means the highlighted buttons will only be styled if the user has javascript enabled and then we hard code the .on class for the first tab in the slideshow navigation:
<ul class="slides-nav">
<li class="on"><a href="#slide-one">Slide one</a></li>
<li><a href="#slide-two">Slide two</a></li>
<li><a href="#slide-three">Slide three</a></li>
</ul>
…and voila! Try disabling/enabling JavaScript and refreshing the slideshow to make sure everything still works and we're done!
- Follow us on Twitter, or subscribe to the NETTUTS RSS Feed for more daily web development tuts and articles.
Related Posts
Check out some more great tutorials and articles that you might like
Plus Members
Source Files, Bonus Tutorials and
More for $9 a month for all TUTS+
sites in one subscription.












User Comments
( ADD YOURS )BroOf May 12th
hey nice tutorial! Btw it’s the first female autohr i’ve seen here. Great!
( )Jeffrey Way May 12th
I didn’t even think about that. How fun for Jenna.
( )lawrence77 May 12th
Jeff your new site theme was amazing man…..
Cool designer too and also a coder….
Stephanie May 12th
This is the first female author I have seen here too. I am very happy about that! Guys aren’t the only ones making web sites, ya know!
( )Simona May 14th
Very happy too so she the female power rising
, great tutorial, thanks for sharing.
Guest May 16th
I read this tut because of its a female tuts hahaha
( )Ara May 24th
Me too, hahaha…
Nice works lady
Isaac Seymour May 12th
I’ve seen something like this elsewhere, for emulating the Coda page specifically, but this is so much simpler, and much better explained – just what I would expect from Tuts+ – I might actually be able to implement it now…
( )Dave May 12th
Great Tutorial!! But what kind of people would have Java Disabled ha ha
( )wpheroes May 12th
true!!
( )Raul Riera May 12th
Nice, its not working that well on Safari 4 though… the “box” is jammed to the right
( )Jenna May 12th
Hmm, it’s working fine for me. Did you make sure there is no ‘#slide-{num}’ at the end of your URL when you disabled JS and refreshed?
( )Cyrus Kafai Wu May 13th
Doesn’t work in IE6 it just displays them all on the right side on one line.
Jenna May 13th
It works perfectly in my IE6 (on Windows)… strange. Perhaps paste the exact URL you are accessing with these problems and I will try to debug it.
Brian Klepper May 12th
No problems in Safari 4 for me!
( )Greg May 12th
What a great tutorial. I will be using this one for sure!
( )- Greg
Jack Earl May 12th
Thanks for the breakdown of whats going on. I spent an hour last night trying a similar tutorial with no luck. But this looks like something I can follow along with and understand.
( )crysfel May 12th
woawww…. i really like the non-javascript technique.
thank you so much Jenna
( )Thomas May 12th
Just what I’ve been looking for. Great article Jenna!
( )Snorri - Css May 12th
nice 1
( )Myfacefriends May 12th
Thanks Jenna your the best! cheers!
( )Bbykcakkr May 12th
Awesome tutorial just what im looking for!
you’re really cute
( )Fynn May 12th
Wow… I just needed something like this in a project I’m working on!
Great! And by the way nice to so see a female author
( )Adam Wiggall May 12th
Hmmm, like Raul Riera it doesn’t work for me in Safari 4, otherwise a great tut, thanks.
( )Joe May 12th
Cool girl
( )Noma May 12th
Very nice tutorial! Thanks for sharing.
( )Philo May 12th
Great Article!
( )lawrence77 May 12th
The first female author rocks….
( )Felix May 12th
Cool tut, but the no-JS technique doesn’t work in Opera 9.5 either :/
( )Goldeneye May 12th
thank you for the nice tut!!!
( )its great.
James May 12th
Nice tutorial and kudos on making it work (mostly) without JS but, as mentioned, the non-JS fallback doesn’t work in Opera.
( )Jenna May 12th
Uh oh… I have to confess to not testing it in Opera (bad Jenna!) =P
Strange that it wouldn’t work though. I mean, it works perfectly in IE6!
If I manage to figure out a nice way to fix it in Opera then I’ll be sure to let you know. It’s currently tested and working in IE6, IE7, Firefox, Safari and Chrome.
( )Thomas Milburn May 12th
You can make this work in all modern browsers using CSS alone by using the hover and active pseudo-classes. This site has a huge list of examples http://www.cssplay.co.uk/menu/
mokin May 12th
Cool girl and tutorial !
Thank for tutorial function without JavaScript.
I want You tut.
look like
http://www.lanrentuku.com/lanren/jscode/js-0192/
with jQuery.
Thank again.
( )brian May 12th
cool tut, but doesnt work all too well with javascript disabled in ff 3.0.10
( )SiGa May 12th
… got the same browser and didn´t recognize any problems… just don´t forget to refresh after disabling JS, as she mentioned…
( )jem May 12th
works fine for me
( )SiGa May 12th
Very useful, thanks for explaining that, Jenna!
( )wpheroes May 12th
Great techniques, thanks.
( )Dario Gutierrez May 12th
Great tut, I want to use it in my site. Thanks for sharing.
( )Thomas May 12th
Is there an easy way to make a previous/next buttons instead of a tabs?
( )Elli August 5th
I’m also wondering this. (:
( )Elli August 8th
Oh, I figured it out this way:
1) In the slideshow.js file, find “pause: true” and replace it with this:
pause: true,
next: (”#next2″),
prev: (”#prev2″)
No comma on the last line, otherwise it won’t work.
2) Create a three-column table. In the first column, add this:
Prev
In the second/middle column, have and so on.
In the third column, add this:
Next
And that should work. Did for me anyway.
http://www.twicebakedfx.com/v34
^ View Page Source
Elli August 8th
Oopsie:
<a id="prev2" href="#"> Prev </a>
<a id="next2" href="#"> Next </a>
Mana October 28th
It’s working perfectly! Thanks Elli!
FireDart May 12th
I spend 3 day’s looking for an auto scrolling content slider and here it is the next day! Wow…… Great tutorial btw, great job!
-FireDart
( )Jarod May 12th
Good stuff. Nice, clean, and effective.
( )Matt May 12th
Very nice!!! using it already… with a little twist! How about the same for the Mootools framework?
( )John May 12th
Sweet! I was actually just having some problems with this while designing as new layout. Thanks much.
( )Lau May 12th
This is pretty nice stuff… Im gonna see if i can use it on one of my sites
( )Thank you
Gabriel Amorim May 12th
:O
OMG please don’t stop this cool work! Make us happy with more!
My congratz, thank you.
( )Idowebdesign May 12th
Thanks Jenna ! Really nice and useful article !
( )mrjacob May 12th
Hott stuff, Realy nice…
I wonder how you get a slide box like that…
or some else jquery plugin on a skew position?
like 30o Degrees..or something.
Is it out there?
someone?
Thanks
( )J May 12th
Good to see a girl out here. Nice tutorial.
( )Evan May 12th
Fantastic article. Working on something like this as we speak
( )Carl - Web Courses Bangkok May 12th
Really nice ! I am going to use this for a hosting web site we have been asked to design for.
Also really nice to see graceful depredation
How graceful you are Jenna.
( )Diego SA May 12th
Loved this stuff! Is it possible to insert images with text? It’d be perfect in a home website. Thanks a lot!
( )Christian Beikov May 12th
Thanks, really nice tutorial!
( )Mysticpixels May 12th
Awesome usage of CSS and JS. Great Graceful Degradation Implemenation technique used. Looking forward for more such inspiring articles. Nettuts just rocks !
Btw, you saved a day of mine …. this was exactly what i was luking for, for the last week … thanks netttus and a ton to Jenna Smith
( )Guillaume May 13th
Great stuff ! Rare to see a girl posting these kind of tips
( )Vince May 13th
Great tut. Using a similar solution for a project I am building now. I am using the jQuery Cycle though.
( )imsraaia May 13th
cool….
( )Raymond Selda May 13th
This is really nice. I like the overall feel. I also wrote an article similar to this one. Thank you
( )xzibbit May 13th
this is very nice, thanks for your support
( )ThaClown May 13th
Thanks alot! Really nice
( )gfx May 13th
without javascript? jQuery is a javascript library!!!
( )JJenZz May 13th
It is indeed =)
without javascript means, with javascript disabled. Try disabling javascript in your browser and click the tabs… you will see it still ‘functions’
Sorry for the confusion.
( )saurabh shah May 13th
nice work jenna… its cool as u
.. thnx for sharing
( )Martyn Web May 13th
Nice work,
I’ve seen some examples of this before but not so simple, can’t quite remember where so I’ll guess Its another bookmark for me.
( )riko May 13th
Excellent ….. 10/10
( )Oliver May 13th
Perfect. Exactly what I’ve been searching for for weeks now. Thank you.
How do I stop it from auto scrolling though, I would just like the links to initiate the effect?
Thanks again.
( )Oliver May 13th
Figured it out if anyone else wanted to know. Very simple. I kicked myself…
just change the timeout to 0 on the slideshow.js
Once again thank you for this invaluable tutorial.
( )JJenZz May 13th
In case anyone has any more similar questions to this, the jQuery cycle Option Reference page explains what options are available and what they do:
http://malsup.com/jquery/cycle/options.html
paul May 13th
It would of been nice if the css was explained exactly what is happening in the background at to why it isnt showing and then why it is?
Perhaps you could explain it to me over dinner?
come on cant blame me for trying
good tut though keep it up!
( )Mike May 13th
Excellent job smarty pants!
( )Shawn May 13th
Just spent some time experimenting with this tut in expression engine, and it works perfectly even with Javascript turned off! This would be a great solution for a front page image rotator for featured content.
Nice Job!
( )GeemeeTheway May 13th
Great! Thank you so much !!!!
( )v-render May 14th
great work .. thanks for the share and exact tutorial
( )Jamie May 14th
Love it but in IE6 if you don’t have the JQuery stuff linked in then it doesnt work.
For example http://www.broadlandhousing.org/dev/scroll/ – this is just pure XHTML and CSS works fine in Firefox, IE7, IE8 however in IE6 it doesnt work it bunches the boxes together
( )Jenna May 14th
Oh no! So it does… it seems I missed a line of CSS when I was typing up the tutorial.
Just add ‘width: 960px;’ to the ‘#slideshow .slides {’ selector below the ‘overflow: hidden;’ property and it’ll work fine.
I have contacted Envato to get this fix added to the tutorial above.
Thank you for letting me know =)
( )B May 15th
I’m not worthy. Thanks!
( )takingweb May 15th
fantastic!!!!….I spent 3 days looking for a scrolling compatible with another js i use and at least here it is!!!!!!!
thanks a lot!!!!
( )Mike May 15th
Nice work, Jenna
( )Brandon May 15th
Jenna,
Great tutorial, it has been very helpful. One question, I’ve tried using the “easing” effect but I am not sure how I need to implement it into “slideshow.js”. I’m trying to do the “scrollRight (click)” effect on the http://malsup.com/jquery/cycle/ homepage.
Any suggestions?
( )John Sanders May 15th
Great tutorial Jenna, thanks.
( )b00m May 17th
Great!
( )Thanks a lot for Jenna!
Bruno May 17th
Great job Jenna,
How do the same slideshow with a vertical tab ?
( )Guest May 17th
I can’t believe that so many people still doesn’t know this, or you’re just making a fool of yourself because the author is a girl and your online with a different world. I’m not gay though look at my comment above.
“I read this tut because of its a female tuts hahaha” but after really reading
through the tuts, it’s just an overflow:hidden on the parent container with a lot of long child container width and adding an anchor to those ids. You guys out there (or kids I guest) can’t believe it you’re just making fool of your self.
I’m saying those say thanks and all that but who really doesn’t know well good for you.
( )Steven May 20th
I’m so impressed that you already knew this so go ahead and give yourself a pat on the back. I’m pretty sure that at one point you probably didn’t know this either. Do you think that every web developer in the world started learning at the same time like it’s some kind of race? I suppose you’ll win this race because you already know everything or you’re just a little ahead of us all. Maybe you just got dumped by your first girlfriend last week in gym class and you’re still upset about it. Is that it? Please, go waste white-space somewhere else next time you have a personal problem. But before you do, I suggest you start paying more attention and study harder in English class.
Now I would like to say thanks to the author of this excellent tutorial. It has bee of great use to me. Please, keep making more!
( )Eric Santana May 18th
Great tutorial. I needed something quick for a client to show some slide show functionality for a design concept. I look forward to reading more of your tutorials, Jenna.
( )John May 22nd
Awesome tutorial, how would you add a “Pause/Resume” function?
I’ve been trying the code below but it doesn’t work
$(’#pauseButton’).click(function() {
$slideshow.cycle(’pause’);
});
$(’#resumeButton’).click(function() {
$slideshow.cycle(’resume’, true);
});
Any ideas? thanks!
( )JJenZz May 25th
Hi John,
I have added the changes you need to pastie.org (plus some small refactoring to make life easier)
http://pastie.org/private/ektoekkwekv3n31flbfc7q
Let me know if you need help understanding any of the code
( )Brian May 25th
How about a way of stopping the slideshow once one of the buttons has been clicked? Without adding a play/pause button?
Sam May 26th
The Jquery Cycle Plugin is wreaking havoc with transparent png backgrounds in ie7. I’ve been googling all day but to no avail. Does anyone have a suggestion for this?
p.s
Maybe something to do with cleartype?
Thanks In advance.
( )Christopher Hein May 26th
Love this tutorial, is there anyway to detect which tab is being click by the user in order to cause the fx direction to change, such as if the user is on slide 3 and clicks slide 2 it would “scrollRight” instead of “scrollLeft”.
I’ve been playing with the functionality but I can’t seem to figure out how that would work.
Suggestions?
( )Jenna June 7th
You can try adding multiple comma separated effects to the ‘fx’ option to acheive this:
http://malsup.com/jquery/cycle/multi.html
( )Kennedy May 26th
What would i need to change in jquery.cycle.js to display more than one slide?
( )Jenna June 15th
tbh, I’m not entirely sure… I am trying to figure this one out myself for a project I am working on so I will let you know if I solve it =)
( )Graphic and Web Designer May 26th
Extremely useful. Definitely going to try it out.
( )Kiran Patel May 28th
Dear Jenna,
Thank you for the wonderful tutorial and its been great to learn as i;m complete begginer; i got one question though in IE it does not pause like it does in Firefox etc. so can you tell me how i can fix that?
Regards,
( )Kiran
Kiran Patel May 28th
The problem was solved so ignore my question. The tutorial was great though!
( )DD May 28th
Great stuff. Unfortunately, your code is not compatible with jquery.ui found at http://jqueryui.com/
I’m attempting to replace jquery.ui’s tabs function with your code, but your code kills other jquery.ui functions already in place.
( )shashank October 12th
u need to check the document.ready() function
( )Seo Specialists June 2nd
Nice Posting. Thanks
( )Dave June 6th
Opera 10 isn’t liking the javascript. The page loaded the nav but nothing else. This could also be something I’ve done though since I had to alter the html to use divs instead of ul and li.
( )Dave June 6th
Ah, my problem was something I caused by trying to fix the no javascript in Opera issue.
( )Dave P June 7th
Great tutorial, very useful!
I’ve been looking for a way to add a link from within slide-one to say slide-four but not having much luck…
Any suggestions appreciated!!
( )Dave P June 7th
Okay, so worked out a solution…
Within slide-one add your link with id=”direct” and href=”#”
In slideshow.js, add the additional lines at the end of prepareSlideshow:
prepareSlideshow: function() {
$(”div.slides > ul”, $slideshow.context).cycle({
fx: $slideshow.fx,
timeout: $slideshow.timeout,
speed: $slideshow.slideSpeed,
fastOnEvent: $slideshow.tabSpeed,
pager: $(”ul.slides-nav”, $slideshow.context),
pagerAnchorBuilder: $slideshow.prepareTabs,
before: $slideshow.activateTab,
pauseOnPagerHover: true,
pause: true
});
// direct link to slide-two
$(’#direct’).click(function() {
$slideshow.tabs.eq(1).trigger(’click’);
return false;
});
}
When you specify $slideshow.tabs.eq(1) you are tell the browser to jump to slide-two, since the first slide is eq(0). You can obviously change this to eq(2) for slide-three, etc.
( )Dice June 8th
For previous and next buttons you got to add two things, in the slideshow.js add in:
next: ‘#next2′, // moves forward to next slide
prev: ‘#prev2′ // moves backward to previous slide
This goes right under ” pause: true,” around line 32.
Then in the html:
Prev Next
( )Eric June 8th
Thanks for the tutorial, very useful.
One question – if I want to place my anchor links (the ones in slides-nav) inside a , it starts to break. I assume there’s somewhere in the JavaScript that needs to be changed to locate the anchors. Any help?
( )Eric June 8th
Sorry, my HTML tag got stripped. My question was, if I want to place the anchor tags inside a Paragraph tag, what do I need to update in the JS? Thanks!
( )Dice June 10th
Just came across an issue with javascript turned off while using a large number of slides. The slides are positioned under each other and are partially visible.
to resolve the issue just add the following to your css:
#slideshow .slides {
height: *how ever many pixels your slides are*
}
then:
.js #slideshow .slides {
( )height:auto;
}
maDnes June 14th
I just stumbled over a bug with this method.
I am applying a background image to the #slideshow div through css:
background: url(background.png) top center no-repeat;
While firefox is showing my background fine through the text in the slides, in IE7 it seems to be forcing a solid color background on each of the items.
After some more research I found that with javascript disabled I can see the background fine in IE too, so this leads me to believe that the issue resides in the javascript file somewhere. Is this script forcing some background property in IE?
Here is an image of the problem in question:
http://xpand2.no/slideshow_bug.png
I really could use some help here, as I am out of ideas of what to do next.
I quickfix was to apply the background image to each item, but that will cause the background to scroll with the slides, and I do not want that to happen.
Any help is much appreciated!
( )Blaine June 21st
The Cycle plugin provides a fix for this. Just add the following option:
cleartypeNoBg: true
The following link provides an in depth explanation.
( )http://www.mail-archive.com/jquery-en@googlegroups.com/msg71747.html
David July 24th
This is really nice, but I’m having the same problem as maDnes with the forced bg color in IE, I had a look at the link that Blaine provided, but I don’t know where to put the code.
I tried a few places but no luck, if someone could tell me where to put this fix it would be greatly appreciated!
Thanks
David July 24th
Worked it out, and if anyone knows as little as me when it comes to js, just put the
cleartypeNoBg: true
in the
$(’div.slides > ul’, $slideshow.context).cycle({
field in the slideshow.js file.
not sure if theres a better place for it, but it works
Laura Volpe June 16th
Hi Great Tutorial!
( )I have a question… how can i stop the auto-scrolling???
Jenna June 28th
Just change the timeout to 0 to stop the auto-scrolling =)
( )miaJ June 18th
Thank you so much. I was looking for this.
( )I’m using it to change images. How do I change the transitioning? I want the images to come on top of one instead of sliding to the left
Josh Clark June 18th
Just change the “fx” on line 7 of slideshow.js from ’scrollLeft’ to ‘fade’
( )miaJ June 19th
Thank you so much!
Josh Clark June 18th
Jenna-
Thanks for a great tutorial and an awesome solution to a problem that’s been vexing me for awhile. I have clients who ask for this functionality all the time, and your solution solves a couple delivery issues I’ve come across.
1. The use of the cycle plugin allows different transition types, including fade for clients who don’t want a scroll.
2. The ability to set a timed interval for auto-transition is really helpful.
3. It gracefully degrades! Someone above asked who doesn’t have JavaScript enabled, but I’m beginning to think the 5% who do turn off JS are all my clients these days! :0)
Again, Jenna: Bravo…you’ve helped me out tremendously!
( )Alex June 19th
Thanks for this great tuto…
timeout: 0 if you want to disable the auto animation…
( )Boris June 21st
Thanks, it’s awesome!
( )Nathan June 23rd
Hi Jenna!
Great Tut, love it!
But in IE7 I seem to get a scroll bar on my containing element that will scroll everything a quarter of an inch but the slide tabs. Any suggestions?
( )Paw June 26th
Thanks for sharing this article! Great stuf!
( )winter bugahod July 9th
tnx for your sharing god bless
( )Henrik Bondtofte July 23rd
Thank you so much for sharing.
( )jeff July 29th
Wow… that was ridiculously easy. I remember being scared off from looking at the source code from something like smoothgallery (I’m a designer, btw). Jquery seriously just makes life easier, it’s not even funny.
Thanks for sharing.
( )Elli August 8th
Is there any way to resolve the cleartype issues in IE? I have
( )cleartype: !$.support.opacity,
cleartypeNoBg: true,
In the slideshow.js file under fx: ’scrollLeft’, but it’s not working. =\
Elli August 8th
Nevermind. Fix:
(slideshow.js)
fx: ’scrollLeft’,
cleartype: !$.support.opacity,
cleartypeNoBg: false,
(CSS)
( )#slideshow .slides li {
background: transparent !important;
width: 920px;
float: left;
padding: 20px;}
Adam August 13th
Hi, great tut! I’m trying to make the slide effect happend not when I click the nav link but when I hover it?
( )Dragon August 18th
Me too.
Also, are we limited to what can semantically be put into an li?
( )Daniel August 22nd
Hi, i have a problem.. i can’t set the height:auto option in the script slideshow.js ( http://malsup.com/jquery/cycle/options.html ).
for example If i set Height:’300px’ it works but when i set Height:’auto’ the script adds in the inline style the height of the bigger content.
could you help me please ?
( )Gloria August 26th
This is exactly what I’ve been looking for!!!
Thank you!
I’m having one slight problem though. I put images instead of text in, and I can only see the very top of it — I’m not sure what setting needs to be changed…can you help.
Thanks!
( )Radu September 4th
Couldn’t you make the tabs appear “selected” without javascript by using :active?
( )Ernie September 7th
Hi this is a great script. How can set up multiple instances of this system on a page?
( )Jen Wilson September 12th
iv’e been trying to make this fit into a variable width layout. i tried putting the widths to % and auto- but it doesn’t degrade welll when the javascript is turned off. so, i tried constraining the height- and putting overflow to hidden. any suggestions?
#slideshow {
width: 100%;
background-color: #eee;
border: 1px solid #ddd;
height:200px;
}
#slideshow .slides {
overflow: hidden;
width: 100%;}
#slideshow .slides ul {
width: 100%;}
#slideshow .slides li {
( )width: 90%;
float: left;
padding: 20px;
height:200px;
overflow:hidden;
}
Alex September 21st
Can I call one of the slides from another page using an anchor? I’ve tried but no luck….
( )Karthick.R.S September 22nd
Hi jenna
Very useful tutorial for web developers.
But is it possible to create fade in and fade out effect when scrolling right to left?
Help me to greatly appreciated. Im not familiar with js
( )SØGEMASKINEOPTIMERING September 24th
Im gonna use this…
( )Jason September 30th
For a partial fix to make the scrolling function in Opera without JavaScript, add this Opera filter to your CSS:
@media all and (-webkit-min-device-pixel-ratio:10000),
not all and (-webkit-min-device-pixel-ratio:0) {
#slideshow .slides {overflow-x:scroll;}
}
This will allow Opera users to still access the slides without JavaScript. Unfortunately, it adds an ugly scrollbar, but depending on your design, this could be hidden by layering an element over the scrollbar.
( )Joe October 11th
I love the smooth transitions.
( )Marcel October 24th
FYI, to make my navigation show up, I had to copy and paste the non-minified version of Cycle from the demo page: http://nettuts.s3.amazonaws.com/325_tabbed/demo/js/jquery.cycle.js
Might want to clarify this under Step 4?
( )Petsen October 26th
hm… seems like it doesn’t like PHP files… the source files work just fine on FF3.5 but the same content inside a PHP file doesn’t.. weird.
P.S.
( )Very nice tutorial!
Petsen November 10th
nvm… a simple typo can ruin your day…
( )gp sidhu November 4th
hi mam thanks for this wonderful tututorial
( )now what i am trying to do is integrating this in another web page but when i test on the local server it works fine but does not work when uploaded to the server
please help!!!
David Moreen November 12th
Jenna, thank you for this great tutorial. One thing that every designer needs to bare in mind while making a project with javascript is that everyone will not have javascript turned on, so the site still needs to function well. Something similar to this will be included in every website that I construct from now on.
( )Joe November 17th
First off, thanks so much for supplying the info and code for this application! Quick question, how customizable is it? Would it be possible to switch the orientation of the layout so it displayed vertically?
Basically, what I would like to do with it is have the links on the right side and have the information display to the left of the links. Similar to the main news section here: http://ca.msn.com/ at the top left under the nav bar, but have the links on the right and the info on the left.
Would it just require some tweaks to the css or is this not possible?
( )