written on:6 Jan, 2009 by Alen Grakalic

jQuery plugin - Easy Image or Content Slider

Delicious StumbleUpon Reddit Subscribe

Click here for the new version of this plugin

This is my first jQuery plugin. I wrote several jQuery scripts but never made a real plugin just because I was I afraid of it's complexity. It turned out to be a lot easier than I thought so I went ahead and created this one.
Easy Slider (as I call this plugin) enables images or any content to slide horizontally or vertically on click. It is configurable with css alone. So, basically you link to plugin file, set the content up and style it with css.

Download easySlider.zip

Getting Started

First you'll need content and it should be wrapped inside a div containing an ordered list where each list item represents one slide. Here's a markup example:

<div id="slider">
	<ul>
<li>content here...</li> <li>content here...</li> <li>content here...</li> ... </ul> </div>

You can basically put whatever you want inside list items as long as you keep the same dimensions. My initial idea was to use this slider for image gallery as on Templatica's homepage but I've used it for other stuff too.
To activate the script you will need to download the files, place jQuery file and easySlider.js somewhere on your site and link to them:

<script type="text/javascript" src="/js/jquery.js"></script>

<script type="text/javascript" src="/js/easySlider.js"></script>

The action starts when you add this lines of code to your JavaScript:

$(document).ready(function(){
	$("#slider").easySlider();
});

This basically initiates the script on page load where "#slider" is css selector of the element(s) that you wish to apply script to. You can also use multiple elements using their class names i.e. $(".list").easySlider();

Next is up to your preferences - styling. This is how default styling looks like:

#slider ul, #slider li{
	margin:0;
	padding:0;
	list-style:none;
	}
#slider, #slider li{ 
	width:500px;
	height:200px;
	overflow:hidden; 
	}
span#prevBtn{}
span#nextBtn{}		

Not much there, is it? The most important thing here is to keep the same dimensions for the content area and each list item (slide). Also, overflow:hidden is obligatory. Other than that, you have free hands in adding your own style to the Easy Slider! To get an idea how it can be spiced up, you may take a look at Templatica's homepage.

How does it all work

Script automatically adds "previous" and "next" buttons in form of span elements with nested anchors just after the content element. Spans have assigned IDs that you can use for css selecting:

<span id="prevId"><a href="javascript:void(0);">Previous</a></span> 
<span id="nextBtn"><a href="javascript:void(0);">Next</a></span>

On each click (previous or next button) script calculates the current "position" and makes a one step in requested direction. So, the slider jumps from one slide to another. Once it reaches the end (last slide), the "next" button fades away and re-appears only if "previous" button is clicked again. Same goes for sliding towards the beginning.

Options

The following options are configurable:

  • prevId - id for "previous" button
  • prevText - text for "previous" button
  • nextId - id for "previous" button
  • nextText - text for "next" button
  • orientation - horizontal or vertical, horizontal is default and if you want vertical set this to 'vertical'
  • speed - animation speed in milliseconds, default value is 800

Yes, you saw it correctly, vertical sliding is also possible! :)

Options are added when calling the script:

$(document).ready(function(){ 
	$("#slider").easySlider({
		prevText: 'Previous Slide',
		nextText: 'Next Slide',
		orientation: 'vertical'
	});
});

Make sure that you don't put the comma after last option.

Demos

Here are some blank, non styled demos. Check out the script in action:

To check out styled demo, please visit Templatica.

What makes this slider script different

Because of it's simplicity and light-weightness (is that a word ?! ) I believe that is is much easier to deal with this plug in and configure it. The appearance is totally editable with css so all of you afraid of getting their hands dirty with JS code can easily use this.

Enjoy!

About the author

cssglobe's image

Designer, developer and a passionate standardista. Long time web professional with huge experience in all types of front-end work. Founder of Css Globe and creator of Easy front-end framework.
To get in touch, visit Alen's personal page, follow Alen on Twitter or become a Facebook friend.

Enjoyed the article?

Then don't miss our next one! Subscribe to our RSS feed or share it with your friends.

Delicious StumbleUpon Reddit Subscribe

Read more! Here are our most recent articles:

View All Articles

Comments

  1. Martin Muehl 6 Jan, 2009

    Great slider and just in time for one of my new projects!
  2. cssglobe 6 Jan, 2009

    @Martin: offtopic - see you in Klagenfurt for IM Austria? :)
  3. V1 6 Jan, 2009

    the example markup you give does not match with selectors you are using in your script. Might be something to fix before it confuses people :)
  4. Chris Barnett 6 Jan, 2009

    Looks good. Will see if I can manage to style up those prev and next buttons.. Thanks for the article, good work!
  5. cssglobe 6 Jan, 2009

    @V1: thanks for the heads up! I renamed the elements several times while writing this article, hence different names. Fixed!
  6. crs 6 Jan, 2009

    So simple and effective! Well done Alen!
  7. andreas 6 Jan, 2009

    Very nice! :-)
    One thing that went wrong when I tried it the first time:
    I clicked on the "Next"-link, watched the nice slide, clicked again for the next pic and was surprised that it showed the first slide again!
    Why: because I didn't recognize that the "Next"-link moved to the right and has been replaced by the "Previous"-link...
    I'm sure this will happen to many users as links are normally not changing positions :-)
  8. Pieter B. 6 Jan, 2009

    It's a very nice plugin!
    I'm probably going to use this when needed.

    As said before, I'd try to do something with the replacement of the 'Next'-link.
    Also, when on the last image, there could be a 'Back to First'-link or something.

    Good job!
  9. cssglobe 6 Jan, 2009

    The thing is, I offered blank, non-styled demos... just basic markup, no real styling... on Templatica homepage I have styled buttons, and properly placed. I will add another full styled demo soon.
  10. Brenelz 6 Jan, 2009

    Wow.... This is a great JQuery slider. I love that you allow us to style it any way we choose.

    Is there any way switch content / images after a set time limit?
  11. Brandon Cox 6 Jan, 2009

    Very nice. Not only is it a nice plugin, it's also a confidence builder for me. I still have that feeling that writing a plugin is beyond me just a bit. Thanks for the boost!
  12. Al 6 Jan, 2009

    Nice job. Thanks for sharing.
    Pretty good for your first one :)
  13. mbh 6 Jan, 2009

    Alen ... great work. One devils advocate question... what's your take/opinion on the user having javascript off?

    I ran a couple of quick test in firefox and unless I missed it yes the content becomes inaccessible. Sure, what are the odds on the average user having javascript off... yeah probably low but...

    I unless I missed something we'd just be of the take of hey if a particular piece of content is important don't place it in the slider. This is absolutely not knocking your work as that stands on it's own merit... it's just the okay do I take a chance with content or is their a parachute option of some sort.
  14. cssglobe 6 Jan, 2009

    @mbh actually, content could be accessible if we tweak things a bit. Removing fixed size for container (#slider) and adding it with JS would do the trick. I will do that.
    Thanks for the comment.
  15. cssglobe 6 Jan, 2009

    @Brenelz it could be added to the script yes. I wanted to keep the basic functionality for this first version.
  16. Ozh 6 Jan, 2009

    Pretty cool. Add ajax image loading capabilities and that's awesome :)
  17. Graeme Mac 7 Jan, 2009

    To add to @Brenelz's comment, I'd also be interested in learning how to auto-rotate the content. If you have the time to help us learn how to add that functionality it would be most appreciated.
  18. Fabryz 7 Jan, 2009

    Very nice plugin, tagged!
  19. Matt Williamson 7 Jan, 2009

    Is it possible to show multiple items at once, like for pagination?
  20. Raymond Selda 7 Jan, 2009

    Wonderful plugin! I hope this will be featured as one of the top JQuery plugins. Thank you for sharing.
  21. Gerd 7 Jan, 2009

    A great jQuery plugin!
    Thanks for sharing.

    Like @andreas, i was a little bit confused, when clicking the link for the non-styled slider for the second time and seeing the first slide again.

  22. cssglobe 7 Jan, 2009

    Thanks for the kind words guys. Sorry about non styled version, but in my experience it's easier to use something when it's bare-boned.
    I am preparing several full styled "skins" for my next article so stay tuned :)
    Thanks!
  23. Janko 7 Jan, 2009

    Looking great, I was thinking of creating something like this on my blog.
  24. Elena 7 Jan, 2009

    This is very simple and very usefull, just what I needed. Thank You!!!
  25. Richard Standbrook 7 Jan, 2009

    Looks great, nice and simple. What about auto-rotating as has been mentioned. And as a jQuery newbie, is it possible to change the transition effect, to kind of bounce the slides or ease them in and out?
  26. Jason Judge 7 Jan, 2009

    Just a note on the demos: the next and previous links should not jump about like they do on the first and last items in the slider sequence. Either place them on the left and right sides, or grey them out once they are no longer relevant. As it is now, the 'next' link under the mouse moves as soon as it is clicked.
  27. renjunlong 7 Jan, 2009

    WOW,Great Job!Thank you very much!
  28. Designer 7 Jan, 2009

    absolutely impressive and very useful script.........thanks
  29. komax 7 Jan, 2009

    Hi,

    thank's for your beautifull plugin, one question ...
    is possible insert horizontal slider inside vertical slider?

    I need to slide 4 vertical image (floor plan) but I need that each one have left and right slide.

    Thank's

    Komax
  30. Fouad Masoud 7 Jan, 2009

    this is kinda fun since i took it off ur other site when it was first released online :D but i had to go with something else that i tweaked a bit. i gave it up coz of a layout issue i had where i needed to get the next and back arrows out of the over-flow: hidden; box. i tried to tweak it and got somewhere close to fixing this issue. ill digg it out and post it.

    i don't know if u updated the plug-in or not. ill check it 2night after work :D

    by the way gr8 work and thank you for making it standard complaint. since there are some implementations out there but most dont validates or are using non-logical markup.

    gr8 stuff
  31. Mayco 7 Jan, 2009

    Muito bom seu trabalho, esta de parabéns!

    Direto do Brazil!!!!
  32. ignari 7 Jan, 2009

    Great plugin Allen. I would also add:
    $('#prevId, #nextId').attr('href', 'javascript:void(0);');

    To avoid writing that directly in the content.

    Ignacio
  33. ignari 8 Jan, 2009

    nvm my previous comment, I thought the links were in the html. Sorry :p
  34. Elvis 8 Jan, 2009

    Nice one, a lot more easy than jcarousel!!! Here are my 2 cents: How about an autoscroll function for this gem? The best would be if one could start/stop this autoscrolling via link (probably the autoscrollstate could be saved as a cookie?!?)
    I'll definitive will use this for one of my next projects!
  35. genia 8 Jan, 2009

    Great script,thanks for making it available for free
  36. David Toms 8 Jan, 2009

    can't I just do this with the jquery cycle plug-in?

    .. or scroll-to?
  37. Abhisek 9 Jan, 2009

    This is awesome! Gonna use it!
  38. stalkerX 9 Jan, 2009

    Fine solution!

    Here is my work: jQuery Slider Player (Page in German): http://playground.ebiene.de/1052/jquery-slide-player/
  39. germo 9 Jan, 2009

    great this yes that break of beautiful!
  40. Workingman 9 Jan, 2009

    Any thoughts to making the navigation "circular"? It would be great to have fixed navigation buttons/text in the design of the page. I love the "light-weightness" of the code. (Yes, I think it's a word now!!)
  41. komax 9 Jan, 2009

    Hi,

    is possible slide next and previous outside main layer?
    I need to slide from href and not from selfmade button, is possible call specific function?

    Thank's for help.
  42. Joseph Pecoraro 9 Jan, 2009

    Excellent plugin! I was looking for something like this earlier this week and this really made me happy. Extremely well done.

    One thing that bothered me was the autogenerated next/prev links. In my case I wanted to use existing elements on the page. So I modified the plugin to instead use prevId and nextId to grab existing elements, and just add the easySlider's next/prev actions to those elements unobtrusively. I think its a lot simpler. Here is my sample:
    http://bogojoker.com/shell/

    Is there an advantage to the auto-generated span's that I'm missing?
  43. mohammed tantsh 9 Jan, 2009

    hello nice slider but how to make auto slide ?
  44. Joseph Pecoraro 10 Jan, 2009

    I realize this is the first version, meant to be simple. Also, cssglobe has put in the comments that he is "preparing several full styled skins for my next article" so I know that he will likely update this in the future. But I had a need for some features like looping, autoplaying, and non-autogenerated next/prev links. Since it was GPL I gave it a shot. If you need these features feel free to take a look but make sure you check back for official updates from cssglobe:
    http://bogojoker.com/easySlide/
  45. Joseph Pecoraro 10 Jan, 2009

    @Workingman: Circular navigation. Like loops? I took some time to put this in, because its a feature I wanted too, and it looks like it works pretty well (see above comment).

    @komax, @mohammed: There is a private function inside of the easySlide plugin called "animate". You would want to call animate('next') to move to the next slide. In the case of looping you would want an interval. However to access the specific animate function you would have to modify the plugin (see above comment).

  46. cssglobe 10 Jan, 2009

    If time permits, I will continue to update this plugin, that's for sure.
    Joseph made some alterations. So, all of you that can't wait for version 2, you might want to check that out.
    The thing is, limited functionality was my intention cause I wanted to make things simple and straight to the point. At least at first. :) I enjoy writing short, simple and readable stuff that anyone can use, even a person without any JS knowledge.
    I will keep adding all sorts of things to it, but I'm afraid that it will not be "easy" slider any more. :)
  47. Nitin Parmar 10 Jan, 2009

    Great script. THANKS for making it available.
  48. Joshua (Bada Bing!) 10 Jan, 2009

    This is a great script, thanks 'cssglobe'!

    However, I can't get it to work in my wordpress site.. I think it has to do with the inline javascript which calls the action. But I'm not really sure.. The 2 external javascripts are called on correctly.. maybe it's something else. Could you please take a look at it? Located at: www.ijosh.nl.

    I would love to use this script:)

    Thank you very much!
  49. Necro 10 Jan, 2009

    this is a nice plugin !!
    But... if I wanna put 2 sliders on the same page like this :

    $(document).ready(function(){
    $("#slider_alpha").easySlider();
    $("#slider_omega").easySlider();
    });

    ... The next & prev link don't seems to know witch ID to slide... It slides randomly #slider_alpha or #slider_omega...
    How to fix this ?

    Thanks !!
  50. cssglobe 10 Jan, 2009

    @Necro: use different id names when calling the function:
    $(document).ready(function(){
    $("#slider_alpha").easySlider({
    prevId: 'btnPrev1',
    nextId: 'btnNext1'
    });
    $("#slider_omega").easySlider({
    prevId: 'btnPrev2',
    nextId: 'btnNext2'
    });
    });
  51. Davor Peic 11 Jan, 2009

    Really nice and simple!!

    Thanx Alen!
  52. Brian 11 Jan, 2009

    Great plugin, thinking of using it for a design gallery. How about a variation that works like the one here:

    http://aws.amazon.com/

    Which has paging for each image e.g. 1,2,3,4. It gives a better idea of how many there are than next > and < last do

    Thanks
  53. Phil 12 Jan, 2009

    Hi,

    I think this is really great, but I can't get it to work correctly and not too sure what I've done wrong.

    When I click the next button the next slide appears but it appears lower down than the previous slide. I've linked to a screenshot that shows it better than I can describe!!

    www.siesta-media.co.uk/images/slide_test.jpg

    If anyone could help I'd be greatful.

    Thanks
  54. Merewald Valletta 13 Jan, 2009

    Awesome, thanks. I'm using it on the update of my site. You rock.
  55. Kadir GUNAY 13 Jan, 2009

    Hi, thank you so much for this article. I translated and told on my own site for Turkish web master. And i added a link for the original article.
  56. 5antom 13 Jan, 2009

    Hi Alen, what a lovely plugin. Been looking for something like this for ages. Can it be used to make a drill down menu like that of the i-pod that slides horizontally? like a drill down navigation for complex menus.

    http://www.filamentgroup.com/lab/jquery_ipod_style_drilldown_menu/
  57. ne2d 13 Jan, 2009

    Great plugin! Thanks for sharing.
    But when i put 2 sliders in one page just like in previous comment

    <script type="text/javascript">
    jQuery(document).ready(function(){
    jQuery("#slider").easySlider({
    prevId: 'prevBtn',
    nextId: 'nextBtn'
    });
    jQuery("#slider2").easySlider({
    prevId: 'prevBtn2',
    nextId: 'nextBtn2'
    });
    });
    </script>

    it doesn't work :-( I dont know why. Is someone able to show code or demo?

    Thanks!!!
  58. Joe Weber 13 Jan, 2009

    Thanks Alen, this is very cool. Any way to have it cycle automatically?
  59. Suzy 15 Jan, 2009

    hey alen,
    this is fantastic script. Well done. Im not too familair with jquery but i was wondering how would you approach demo 3 in such a way that the content slides the opposite way first? Inotherwords how would you make the first div slide down as opposed to up when you click the button?
  60. Syl 15 Jan, 2009

    Great script. Thanks for sharing

    How do we style the previous and next to be buttons (instead of text)?

    Thanks
  61. Tim 16 Jan, 2009

    Awesome Script Alen! So Simple! Well done!

    One question though, Is it at all possible to show multiple slides at one time? ie say you have a UL with 8 LI elements, can you show two at once and still skip forward / backward by 1 LI element at a time?

    Thanks again!

  62. Frederic 16 Jan, 2009

    Autoslide !!!! How ? When ?

    :)
  63. Max 17 Jan, 2009

    Great stuff!
    Two quick things:
    Not sure how to style the prev/next navigation? I tried adding CSS to the span#prevBtn and span#nextBtn and nothing happened? I then tried adding the child "a" link anchor and still nothing? How do you style these?

    Also, having a main wrapper with auto centering margins creates a horizontal scroll bar in Safari? I noticed this with another jquery image script as well. Is there a trick to fix this?

    Thanks!
  64. Max 17 Jan, 2009

    Is there a way to present a series of thumbnails(say several rows, driven with CSS) below the Easy Slide window? So you could click on a thumbnail and the full size image would appear in the window with the next and prev navigation ready to activate on that image...

    Thanks!
  65. Max 18 Jan, 2009

    I figured out how to add some styling to the next and prev navigation. Some things just will not work. I cannot get rid of the words. I want to use background images like so:
    span#prevBtn{
    display:inline;
    cursor:pointer;
    background:url(images/preview_prev.gif) no-repeat;
    width:51px;
    height:19px;
    text-indent:-9000px:}

    I have tried experimenting with the display: inline and removing the nextText from the script. Nothing works. I would love some pointers on styling these and removing the actual words...before I go insane!

    Thanks!
  66. Khaled 19 Jan, 2009

    The same question:
    "One question though, Is it at all possible to show multiple slides at one time? ie say you have a UL with 8 LI elements, can you show two at once and still skip forward / backward by 1 LI element at a time?"
  67. dende 20 Jan, 2009

    Hi,
    i also think, a possibility to let it scroll automatically would be great. I have no idea, how difficult an implementation would be, but it should be possible, just like in this slideshow-plugin http://malsup.com/jquery/cycle/ .
    Whatever i like your slider better ;)
    its GREAT :>
  68. Fredrik 20 Jan, 2009

    I am trying to run this:

    <script type="text/javascript">
    $(document).ready(function(){
    $("#slider").easySlider({
    loop: true,
    autoplayDuration: '3500',
    prevId:'prev',
    nextId:'next',
    autogeneratePagination: false
    });
    });
    </script>

    and

    <div class="sliderbar">
    <div style="float: left;">
    <span id="prev"><a href="javascript:void(0);">Previous</a></span>
    </div>
    <div style="float: right;">
    <span id="next"><a href="javascript:void(0);">Next</a></span>
    </div>
    </div>

    With Josephs modification but i can't get it to work. The "Next" and "Previous" text doesn't display.

    What i wanna do is i want it to autoplay and loop, but i still wan't the users to be able to klick themselves to the pic they want to watch, instead of wait until the slider loops and gets to the right spot again.
  69. Gaspard 20 Jan, 2009

    Hi,

    Really love your plugin, I don't know anything about javascript but I implement it quickly to my page. I love the way using list to add images at the slider...

    Is anyone encountering problem with Safari or any other webkit browser, Chrome ...
    My slider works perfectly in IE and in Firefox, but it slide one and a half withe webkit based browser...

    Any idea would be appreciated.

    Really hope you would update this script with some more feature requested by the others comment. My wish would be: is it possible to make content scrollable if javascript is off.

    Cheers, and happy new year.

    Gaspard

    Ps: sorry for my frenchglish ;)
  70. Yman 21 Jan, 2009

    hey ppl, i hav a question here
    i hv tried messing with the js, and i still couldn't figure out how to create a "home" button to return to first page.
    Sorry for the noob question.

    here's the important part:
    if(dir == "next"){
    t = (t>=ts) ? ts : t+1;
    } else if(dir== "prev"){
    t = (t<=0) ? 0 : t-1;
    } else if(dir== "home"){
    t = (t<=0) ? 0 : t-1;
    };

    what should I modify under (dir =="home") condition?
  71. Yman 21 Jan, 2009

    ah, nvm, i some how work it out with a very stupid way :)
  72. cssglobe 21 Jan, 2009

    To everyone: I am creating an upgraded version of this slider that will have autoscroll, a possibility of paging instead of previous/next, first/last button and perhaps few other things as well (throw in a suggestion). Also I will provide one or two fully styled examples.
  73. East 21 Jan, 2009

    Multiple sliders on 1 page would be nice?

    Or is that already possible? I can't get it right.
  74. Nandx 21 Jan, 2009

    First of all, congratulations. Your jQuery plugin is great, very simple to use and works perfectly, but..

    As other people said before, I'm trying to put two sliders in one page, but I cannot get them running. The navigation doesn't work fine when I put more than one slider. I have no idea if it's because I haven't the right code or what...

    Any ideas? Thank you for all.
  75. cssglobe 21 Jan, 2009

    @Nandx and others: I am coding the update for this plugin as we speak, version 1.5 will be published on Friday and it will support multiple sliders. So please stay tuned. Thanks!
  76. East 21 Jan, 2009

    Nice!
  77. Images use instead of text 22 Jan, 2009

    Thanks for sharing this code..

    But I have some quiry if i want to use a images instead of next of previous text then where should i chage the code
  78. Joe 22 Jan, 2009

    Amazing! Can't wait to see the updated version 1.5!!!
  79. jeroen 23 Jan, 2009

    Very nice script. Also waiting for the autoscroll function.
    Is it also possible to use other effects? I want to use the Fade method is this easy to adjust?
  80. Adeline 24 Jan, 2009

    Thanks for the tip, will definitely implement in my next project!
  81. Dee 25 Jan, 2009

    I would like to use images for the previous and next button (as the comment 4 above asked about) and would like to know where I insert that in the code. Please help as soon as you can.
  82. Nandx 25 Jan, 2009

    Sorry, but.. where's the new version 1.5?
  83. cssglobe 25 Jan, 2009

    It will be online tomorrow
  84. Jose Castillo Areiza 26 Jan, 2009

    Hi, I have a content inside each LI tag, I inserted images, paragraphs, but with an UL LI inside they went crazy... is there a solution for this?
  85. cam filmi 26 Jan, 2009

    I would like to use images for the previous and next button
  86. sergey 26 Jan, 2009

    this is a nice plugin!
    thx
  87. zarouk 26 Jan, 2009

    Hi all,

    Great plugin ... thank you.
    Waiting for the new version with the autoscroll function to use it.
  88. Geoff 27 Jan, 2009

    Great Plugin – thanks for the work you've put into it. There are far too many overcooked/frilly jquery image galleries out there. Yours is one of the few nice ones I've found so far.
  89. Nicolas Borda 27 Jan, 2009

    This is a fantastic plugin, I love it! I was looking for something so lightweight and simple for ages. I'm building a Drupal modules that will alow to use this plugin as a way to display views (lists of content made through a ui with the amazing views module). The problem I'm having is that this module prints out field wraped in divs inside the list items. The slider still works, but now you get additional empty slides, one for each nested div inside list items. Is ther a way to support nested divs or other elements in list items?
  90. Nicolas Borda 27 Jan, 2009

    @Jose Castillo Areiza : This happens because each nested element inside list items are considered a slide, like the list item itself. That's why you get the additional slides, and it looks like its going crazy. If anyone finds a way to support nested items in EasySlider please add a comment.

    @cam filmi & @Dee: There would be two ways to do it, one modify the easySlider JS in line 56 and add the image tag inside the anchor. Another way would be to use a CSS image replacement technique, I tried Phark revisited and it didn't work (maybe because of display:inline?), here is a link with most of the tecniques: http://www.mezzoblue.com/tests/revised-image-replacement/

    Change line 56 to something like this:
    $(obj).after('<span id="'+ options.prevId +'"><a href=\"javascript:void(0);\"><img src="images/btn_prev.png"/></a></span> <span id="'+ options.nextId +'"><a href=\"javascript:void(0);\"><img src="images/btn_next.png"/></a></span>');
  91. Andre 28 Jan, 2009

    Is it possible to change the color of the next and previous button? Need some help :-(
  92. Jason 29 Jan, 2009

    Can you give an example of how to use prevId and nextId with an image?
  93. cssglobe 29 Jan, 2009

    @Andre: sure just select it with css #nextId and define the appearance.
  94. cssglobe 29 Jan, 2009

    @Jason: Take a look at the example here: http://cssglobe.com/lab/easyslider1.5/02.html
  95. Sinister Edd 10 Feb, 2009

    I like this script, it was really easy to setup.
    But i have a question,
    I have some links:
    link1 link2 etc.
    I want them to link to a section in the cycle content
    so if i click on link2 it sycles to he section where the content is of link2.

    I hope you could help me with that.
    Thanks in advance.
  96. Dan 11 Feb, 2009

    Anyone having issues getting this to validate in XHTML Transitional? Is it a known issue?
  97. danreb 14 Feb, 2009

    Great this is what I am looking for, simple and sweet. thanks
  98. Jennae Petersen 19 Feb, 2009

    I am completely new to this, so forgive me if my question makes it obvious :) . Where do I put the following lines of code:

    $(document).ready(function(){
    $("#slider").easySlider();
    });
  99. Miles Tinsley 22 Feb, 2009

    Jennae, all you need to do is wrap it in <script> tags and put the code somewhere on your page. Anywhere will do, but it makes sense to put it quite near the actual slider :P

    <script>
    $(document).ready(function(){
    $("#slider").easySlider();
    });
    </script>
  100. nobull 22 Feb, 2009

    to Jennae Petersen

    u need to write an html tag
    <script language="javascript">
    $(document).ready(function(){
    $("#slider").easySlider();
    });
    </script>

    preferably in the head tag
  101. kapil jagtap 25 Feb, 2009

    Very nice work dude.. :)
  102. Val 25 Feb, 2009

    Hi! This is great, just what I was looking for! Helps a lot, thanks for sharing!

    As others have already asked, how could I slide to a particular slide from a pagination, or back to first slide link. Has anyone got a solution?

    Your help would be greatly appreciated!
    Thanks in advance.
  103. Val 25 Feb, 2009

    And the answer to my question is:

    http://cssglobe.com/post/4004/easy-slider-15-the-easiest-jquery-plugin-for-sliding

    :-)
  104. jBay 26 Feb, 2009

    I know there have been many posts for multiple sliders on one page, although is it possible to have two sliders work off of one set of buttons? I want to have an image div and a text div in two different locations, but have them change together. Is this possible?
    word!
  105. Zend 26 Feb, 2009

    Im new to jquery anyone knows how to do this:
    if(options.controlsShow){
    var html = options.controlsBefore;
    if(options.firstShow) html += '<span id="myid"><a href="images/myimg/'+ t +'.gif" id="btnImg" class="btnImg">My Image</a></span>'; $(obj).after(html);
    };
    I want to get the value of ( t ) when I click next then suppose to get the next counter 2, 3, 4 ...
    Any help is greatly appreciated.
  106. josh 3 Mar, 2009

    Nice script. I am trying to figure out a way to call the 'animate' function from another script. Basically I would like to perform the 'NEXT' function from another function.

    I looked into the animate function but I cannot call that from outside EasySlider. Any thoughts?
  107. Peter 4 Mar, 2009

    In section
    "How does it all work"

    span Previous button shoul be prevBtn instead of prevId i think ?
  108. Roki 4 Mar, 2009

    I have created controls on top of the content

    <span id="prevId"><a href="javascript:void(0);">Previous</a></span>
    <span id="nextBtn"><a href="javascript:void(0);">Next</a></span>

    but i dont want controls to be on bottom of the content, how can i hide remove them or move them somwhere else.

    Thanks
  109. Mike H 10 Mar, 2009

    Nice work, light weight and seems to work well.
    In your post though, under Getting Started you've written that the div should contain an ordered list, while your example (and the easy slider code) seems to work with an unordered list.
  110. Peter 10 Mar, 2009

    Nice plugin :) Is it possible to get it to work inside a jquery tab?
    I have this in <head>
    <script type="text/javascript">
    $(function() { $('#container-1 ul').tabs(); });
    $(function() { $('#container-2 ul').tabs(); });
    </script>
    <script type="text/javascript">
    $(document).ready(function(){
    $("#slider").easySlider();
    });
    </script></head>
    The slider keep loading but no images turns up. If I move the slider outside tab it's working.
    Ideas anyone?
  111. Ant 11 Mar, 2009

    why does my setup only play the script properly until you refresh the page, then it bugs up.... it doesn't happen in internet explorer though...
    http://www.lime-five.com/wordpress/wp-content/themes/theme/js/test.html

  112. Peter 11 Mar, 2009

    I found a solution to my own problem.
    I changed all ul-references in easySlider.js to ol and changed <div id="slider"><ul>..</ul> to <div id="slider"><ol>..</ol>
  113. netmastan 12 Mar, 2009

    This is an excellent and simple slider but only problem is controlling the next and prev link. It should be flexible such way that I can move next and prev links anywhere as long as it has an id. if someone can hack this it would be the perfect and compact slider.

    Regards
  114. Joachm 12 Mar, 2009

    Great work very simple for a NOVICE like me. Im trying to work out how to control two or more divs with one function. So they have different timings (Delay)

    So one finishes slding before the other. Any help Please!

    Thanks
  115. SK 15 Mar, 2009

    I have run into problems when trying to populate slider contents via AJax-JSON from Flickr. Here is the code I am trying to use:

    var Slider = {};
    Slider.images = 'empty';
    Slider.imageItems = function(jsonurl){
    $.getJSON(jsonurl, false, function(data){
    Slider.images = '<li>';
    $.each(data.photos.photo, function(i,item){
    var image = '<div style="width:100px;height:65px;overflow:hidden;float:left;margin:5px;">' +
    '<img src="http://farm' + item.farm + '.static.flickr.com/' + item.server + '/' + item.id + '_' + item.secret + '_s.jpg" alt="' + item.title + '" />'
    + '</div>';
    Slider.images += image;
    });
    Slider.images += '</li>';
    });
    return false;
    };

    Slider.init = function(){
    $("#slider").easySlider({
    controlsBefore: '<p id="controls">',
    controlsAfter: '</p>',
    controlsFade: true,
    auto: false,
    continuous: true,
    prevText:'',
    nextText:'',
    prevId: 'prevBtn',
    nextId: 'nextBtn',
    loop: true
    });
    }


    $(document).ready(function(){
    //getting first elements
    Slider.imageItems('/site/objectscarouselimages/perpage/16/page/1');
    $('#slider ul').append(Slider.images);
    Slider.init();
    });

    For some strange reason Slider.images is always "empty" and only populated with images after the line Slider.images += '</li>'; At the document.ready part $('#slider ul').append(Slider.images);, it is empty.
    Something is wrong with the dynamics of the code, I guess. What could be done here?
  116. Allan Fonseca 15 Mar, 2009

    Thanks!! Thanks!! Thanks!! Thanks!! Thank you.....
  117. ortak miras 18 Mar, 2009

    very good, thanks
  118. Noski 18 Mar, 2009

    Hi,

    thanks for making a great slide reel. I know this is a really noob question but how can I add more than 5 slides and will it have an affect on another slider thats using the same code, fi so how can I prevent that?

    Cheers
  119. Noski 19 Mar, 2009

    Tiz ok have just answered my own question doh [:
  120. Tiago Celestino 20 Mar, 2009

    Thank you very much man. The script helped very in my new project.

    hugs!
  121. Jason Geyer 22 Mar, 2009

    This is a really great script; perfect for what i was looking for!

    Is there any way to assign the previous/next buttons to existing images in the page layout without using CSS? My main layout consists of a big sliced graphic, and I really would rather not try to single out 2 small slices to be aligned in CSS if possible.

    Thanks!
  122. Nate 23 Mar, 2009

    I played with it for a couple of hours, I can't get it to work on my Wordpress blog.
  123. Andrei 23 Mar, 2009

    I am using the slider on an ajax enabled asp.net website. The problem is that every time an ajax callback occurs, the "Next" and "Previous" buttons which are rendered from javascript disappear (do not get rendered), even though the javascript code that renders them is executed. I even tried putting everything in a single update panel, but it didn't work. The only way to make it work was to disable ajax, but unfortunately, this is not acceptable in my case.
    Any ideas?

    Thanks
  124. Tim 26 Mar, 2009

    Hey there!

    I am also having problems with this script in Webkit Browsers. They Scroll 1 and a half to two slides at a time, works fine in FF and IE.... go figure! :P

    Anyone got any suggestions?
  125. Enrique 26 Mar, 2009

    Any way to show ALWAYS the "Previous / Next" buttons ?
  126. Drew 27 Mar, 2009

    Beautiful, thank you so much for this.
  127. Charlie Rogers 31 Mar, 2009

    Hi, Guys This pluGin Is fabulous and i do appreciate the Developer Work and Guys can you post these sort of plugins info to my site http://www.gossipinn.com ? I wil be waiting for your responce ThnX and Best Regards
  128. Daniel Craig Jallits 3 Apr, 2009

    @Nate This works for me!

    <?php wp_enqueue_script('jquery'); ?>
    <?php wp_head(); ?>
    <script type="text/javascript" src="<?php bloginfo('template_directory');?> /js/easySlider.packed.js"></script>
    <script type="text/javascript">
    var $j = jQuery.noConflict();

    $j(document).ready(function(){
    $j("#slider").easySlider();
    });
    </script>
  129. José Airosa 15 Apr, 2009

    I really can't get it to work on safari. It simply doesn't work.

    Working on all browsers either on Mac and Windows.

    But safari no good. I tried http://templatica.com/ and it works, so it must be a personal problem, but i can't figure it out.

    Best regards.
  130. Jean Marie 16 Apr, 2009

    Great work!

    Very easy to understand/use, leightweight and fullfilling my requiruements for a content slider.

    Thanks,
    Jean Marie
  131. Zdeněk Doležal 17 Apr, 2009

    Hi Alen,

    Very nice script! I've written something similar some months ago, but yours is better :-).

    I've made one improve into your script:
    Imagine you have three <li> elements visible and want to slide out only one of them. So you have to specify how much you want to slide every time slide-button is clicked. This value is used instead of obj.width() (or height).

    Best regards.
  132. Amit Dixit 20 Apr, 2009

    nice script Allen, thanks for that.
    When we are viewing the first item and when we click on the PREV button it slides the whole slider to the end of the list and shows all the items.
    Can we not slide it backwards to see the last item from the first item?
    Thanks again ;-D
  133. Logan 25 Apr, 2009

    When I put it into my wordpress theme, it doesn't seem to make the up and down buttons? Can somebody help me.
  134. Mike Lewek 27 Apr, 2009

    Hi, I think I have come into some possible interference the script has when using png-24 background images with transparency. I'm not exactly sure, but I'd have to say it's a good guess because I can't seem to find anyone with a similar problem. CIAO.
  135. Mike Lewek 27 Apr, 2009

    Well, scratch that theory. It won't show a jpg either. Maybe a naming conflict...I'll let you know. :)
  136. peter 28 Apr, 2009

    Nice script~~
  137. Mike Lewek 29 Apr, 2009

    Well, I can't imagine it's a naming conflict either. Who knows... Very Nice script btw. Seems to work in every browser I've tried. :)
  138. Bakadesu 1 May, 2009

    I needed the ability to smoothly slide across all images at a constant speed, so I set [continuous: true] and [pause: 0]. However the easing between images disrupted the smoothness I was looking for. So I added the option to control the easing (linear/swing).

    Posted the code here: http://pastebin.com/m7a2bd086
    Added lines: 55, 122, 129

    So in order to get a slider with a constant speed, I used the following options with the modified plugin:

    { auto: true, continuous: true, pause: 0, easing: 'linear' }

    I hope this helps someone. Thanks Alen for the original script!
  139. mike 4 May, 2009

    can it be used to slide flash instead of imgs?
  140. Ankit Sabharwal 5 May, 2009

    this doesn't seem to work for some strange reason ! will have to figure that out ..

    anyways great tutorial !!
  141. Dimitris 10 May, 2009

    That's so beautiful. I was just wondering will I be able to go to next / previous by clicking the slide it self and not by using a previous next link below ?
  142. cmd 15 May, 2009

    I have 2 audio files in slides 1 and 2, first, how can I ONLY start audio 1 when the page loads and have to automatically stop when I click next? In the same way I want audio 2 to begin once slide 1 is hidden. Is it possible to achieve this, pls help!
  143. Sjoerrigter 16 May, 2009

    Thanks for the great slider. I really like it.

    Has anyone tried to implement this in Magento yet? I am trying to get it to work as a custom block. I think i have all the settings right, but is still doesn't work.

    I am trying to install it here: http://www.sjoerrigter.nl/test/medisales/
  144. Hussain 17 May, 2009

    Great job, but what if my content is complex and I need to have nested DIVs inside each content? I do not think it is a good idea to have nested DIVs inside lists... I will be appreciative for your advice..

    Regards
    Hussain
  145. ayoub 19 May, 2009

    I really liked this plugin. I was wondering if it is possible to slide to a specific image or content using this plugin, like (by clicking a button 1 it slides to content 1, clicking a button 4 it slides to content 4 ..) ?
  146. Jonathan 19 May, 2009

    How I can insert elements after dinamiclly?
  147. Mike 20 May, 2009

    When I reach the last picture in the slider, I want to return to the first picture when a users cliks on the "Next" button.
    What must be changed in the code for this option?
  148. Sven 20 May, 2009

    Hi and thanks for that great plugin.

    I have one question (that is also mentioned above): Is it possible to "jump" directly to a specific slide-number?

    I need this for a form that's on the second slide element and that should be opened again if an error occurs after the form is submitted.
  149. Sunil Rawat 22 May, 2009

    the jquery demo is very good but i want to know that can i place next and previous link on any place like on the top or anywhere.
    Plz anyone know the solution for this or any alternative solution.
  150. sjoerrigter 23 May, 2009

    Sunil Rawat on 22 May, 2009 wrote:

    You can change the css styes to position the next and prevous link anywhere you want.
  151. wirpo032 23 May, 2009

    Thx, really...should be more people like you writing such tutorials. Thumbup
  152. Robert 25 May, 2009

    Hello Allen, first up great tutorial. I'm working on my site and I'm using your slider. On my photography page I would like to display 2 rows of thumbs instead of one, take a look at my photography page and you will see how i want it to display.

    If I can adjust the height of the slider to show both rows of thumbs that would be great. Thanks again.
  153. Lorenzo 26 May, 2009

    If I use

    $.get("images.html", function(data) { jQuery(data).appendTo('#slider'); });

    to dynamically add the html <ul>....</ul>, the plugin just load the first image. Why is that?




  154. _Undefined 5 Jun, 2009

    Would it be possible to overlay text on top of images in the slider?

    I've tried a few different ways to go about it using css and a separate slider with just text, but can never get the text to be on top of the image.
  155. Mike Lewe 9 Jun, 2009

    I'm back. Seems I had some sort of server bug.
    Excellent Plugin! Works perfectly.
  156. Umar Zaman 11 Jun, 2009

    Hi,

    Thanks for this slider its really cool i am having small problem that it keeps sliding even there are no images. And also my each li image is 70px X 79px... Please Help
    Thanks
  157. Jonathan 15 Jun, 2009

    I installed the plugin and it seems that the PrevButton and NextButton don't work in Safari and Chrome. Can anybody help please? Example www.iphoneapplab.net
  158. Daveed Flexer 15 Jun, 2009

    To Jonathan,
    I have had no problem with this plug-in in safari/chrome (webkit browsers).

    I am using the text version of prev - next and this is all the CSS I have

    /* Easy Slider */

    #slider ul, li {
    margin:0;
    padding:0;
    list-style:none;
    }
    #slider li {
    /*define width and height of list item (slide)
    entire slider area will adjust according to the parameters provided here*/
    width:400px;
    height:300px;
    overflow:hidden;
    }
    span#prevBtn {
    font-size:0.75em;
    position:absolute;
    right:210px;
    bottom:20px;
    }
    span#nextBtn {
    font-size:0.75em;
    position:absolute;
    right:130px;
    bottom:20px;
    }
    /* // Easy Slider */
  159. Guillermo horno 15 Jun, 2009

    Thanks! very useful piece of code.
    Just one suggestion, I've used it to make a home page slider and inside those slides, I have another <ul> to list some items.
    The code changes the width of the ul inside the slider div (that's needed for the main <ul>, but not for the inside ones).
    I've changed the selector on lines 69, 118 and 124 to be $("ul:first",obj) instead of $("ul",obj).
    Also added some changes to the css <li> attributes, so it doesn't change the widths of the inside <li> :

    #slider li ul li{
    width:auto;
    height: auto;
    }

    Just an humble suggestions, warm regards

    Thanks
  160. nico4peace 16 Jun, 2009

    Hello,

    Is it possible that the slide automatically?
    if so what is the command to add
  161. Lincoln 17 Jun, 2009

    Hello,

    Very nice work with this amazing plugin! I had to use more than one slide per page and I had problems with the following line:

    obj = $(this)

    To fix that I've added a `var' before the `obj' declaration. I did it to ensure that obj will be available only in the local scope, instead of global one.

    HTH
  162. Paul 17 Jun, 2009

    Any update on support for nested lists? I specifically want to be able to nest <ul>'s inside of the easySlider's <li> sliders. mine goes crazy as people have previously mentioned. for now, I guess I can try and not use an unordered list for my content....
  163. Vishal 18 Jun, 2009

    I had run into problem when trying to have two instances of this slider in the same page.

    Can you please give me a solution on how to add two working slider instances in a single page with no script conflicts please?
  164. Adrian G 19 Jun, 2009

    Great slider script looks great on my website.

    Has anyone found a way to make it return to the original position by moving forwards rather then backwards?

    1-2-3-4-5-1-2-3-4-5
    rather then
    1-2-3-4-5
    <-<-<-<-
    1-2-3-4-5

    thanks.
  165. Empee 26 Jun, 2009

    Hi, I saw a few questions about how to put 2 or more images into one page / slide.
    I'm a noob but this is easy. The slider uses <li></li> to indicate where an item starts and ends. so put more items in one <li> and you got it. I use ASP.NET Repeater where item is <li>something and AlternatingItem is something</li>
    hope I helped someone,
    anyway, good thing this slider.
  166. james 27 Jun, 2009

    Hi, Cool slider.
    But I can't seem to change the width of the li that the image or content goes in.
    i tried changing all the widths in the css i could find, but the visible window that shows the content always stays the same size.
    Is there an easy way to basically just make the content area slightly thinner ?

    thanks

    james
  167. Vernon 29 Jun, 2009

    I'm a noob with jQuery. I'm trying to use this on one of my projects but I can't get the buttons to work. What am I doing wrong?

    http://www.perfectsoftware.com/V3/html/text.php
  168. dynagirl 29 Jun, 2009

    Thanks for this very easy solution! Question? How do I center the images that I'm using within my div?
  169. adibu 30 Jun, 2009

    How can I change the order of auto-vertical?

    Now is: 1-2-3-4-5-1-2-3-4-5
    What I want is: 1-2-3-4-5-4-3-2-1

    Is this possible?

Sorry, further comments are disabled for this post.

CSS Globe is a web design magazine brought to you by Alen Grakalic and kept fresh with member contributed news and exlusive articles.

CSSG Ads

Useful Links

Friends