Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Why isn't my J query Slider working?

I haven't took the J Query course just yet, but have found an example online. I got it to work on one site, but when trying it on a new one it is not working. I have took out all the code that is not relevant to the slider, showing below everything to do with it. Any help would be appreciated :)

             <script src="jquery.1.11.0.min.js"></script>
           <script src="jquery.cycle.all.js"></script>
     <script type="text/javascript">
        $('#slider').cycle({ 
            fx:     'scrollHorz', 
            speed:  'slow', 
            timeout: 0, 
            next:   '#next', 
            prev:   '#prev' 
        });
    </script>   

           <style>

                                                   #container{
                            width:776px;
                            height:280px;
                            margin-left:80px;
                            border-left:2px solid grey;
                            border-right:2px solid grey;
                            border-bottom:2px solid grey;
                            border-top:2px solid grey;
                            background-color:white;
                            display:block;
                            float:left;
                            overflow:auto;
                        }       
                        #prev{
                            display:block;
                            float:left;
                            height:280px;
                            width:385px;
                            position:relative;
                            z-index:99;
                        }   
                        #prev:hover{
                            background-image:url(../img/left_arrow.png);
                            background-repeat:no-repeat;
                            background-position:left;
                        }
                        #next{
                            display:block;
                            float:right;
                            height:280px;
                            width:385px;
                            position:relative;
                            z-index:99;
                        }   
                        #next:hover{
                            background-image:url(../img/right_arraw.png);
                            background-repeat:no-repeat;
                            background-position:right;
                        }
                        #slider{
                            display:block;
                            float:left;
                            width:776px;
                            height:280px;
                            overflow:hidden;
                            position:absolute;
                        }
               </style>
               </head>
              <body>

                                                 <div id="container">
                                                     <div id="prev"></div>
                                                      <div id="slider">
                                                      <img src="img/jq/1st.jpg">
                                                        <img src="img/jq/2nd.jpg">
                                                     </div>
                                                    <div id="next"></div>

                                                 </div>
              </body>

3 Answers

Didn't you forget some "<style>" tabs along the way?

Can you be more detailed please, im not sure what you mean by "" tabs ?

Oops, I mean "style" tabs.

<style>
  #header {
    color: red;
  }
</style>

Ohh sorry , i forgot to mention, basically i have an external css filelinked in, i have just put it in without style tags just to show you my css applied.

Did you try after jQuery has loaded? $(document).ready( ... ) ?