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

I'm having problems getting jQuery to run on my website!

I have the jquery library loaded into the head of my website and I'm running some basic single-line code to test, but I cannot figure out why it's not running. The jquery ui and cycle links are also loaded. What i'm trying to do with the code is hide one of the photo links. Any help would be great. I can't figure out what I'm doing wrong. I've downloaded the jquery library to my computer. My code is below:

<DOCTYPE html> <html> <title> Rachel's Website </title> <head> <meta http-equiv="content-type" content="text/html"/ charset="utf-8"> <link rel="stylesheet" href="RachelCssPage.css" type="text/css" charset="utf-8"/> <script type="text/javascript" src="jquery-1.11.2.min.js"></script> <script type="text/javascript" src="jquery-ui.js"></script> <script type="text/javascript" src="jquery.cycle.all.js"></script> <script type="text/javascript">

$(".slider#1").hide("slow");

</script> </head> <body> <!----------------This portion is where the navigation will go----------> <div id="Rachel1"> <nav> RACHEL MILLER-BRADSHAW <ul> <li>Bio</li> <li>Media Gallery</li> <li>Press</li> <li>LHP</li> </ul> </nav> </div>

<!--------------This is where I begin my creating my image slideshow------------> <div class="slider"> <img id="1" src="Allan Houston pic.jpg" border="0"> <img id="2" src="Angela Yee.jpg" border="0"> <img id="3" src="queens library.jpg" border="0"> </div>

</body> </html>

Could you post your HTML and JavaScript code? Also, do you see any error messages in your browser's console?

Also, I don't believe writing .slider#1 is valid selector. Try just .slider without the #1 part at the end.

I don't see any errors in the javascript console. Here's my full html and CSS code:

HTML: <!----RACHEL'S WEBSITE-----> <!--------FIRST THINGS FIRST IS THE NAVIGAATION-----------> <DOCTYPE html> <html> <title> Rachel's Website </title> <head> <meta http-equiv="content-type" content="text/html"/ charset="utf-8"> <link rel="stylesheet" href="RachelCssPage.css" type="text/css" charset="utf-8"/> <script type="text/javascript" src="jquery-1.11.2.min.js"></script> <script type="text/javascript" src="jquery-ui.js"></script> <script type="text/javascript" src="jquery.cycle.all.js"></script> <script type="text/javascript">

$(".slider#1").hide("slow");

</script> </head> <body> <!----------------This portion is where the navigation will go----------> <div id="Rachel1"> <nav> RACHEL MILLER-BRADSHAW <ul> <li>Bio</li> <li>Media Gallery</li> <li>Press</li> <li>LHP</li> </ul> </nav> </div>

<!--------------This is where I begin my creating my image slideshow------------> <div class="slider"> <img id="1" src="Allan Houston pic.jpg" border="0"> <img id="2" src="Angela Yee.jpg" border="0"> <img id="3" src="queens library.jpg" border="0"> </div> </body> </html>

CSS: *{ margin: 5px; }

Rachel1 {

border-style: solid; border-color: blue; border-width: 100%; padding-bottom: 40px; background-color: pink; }

ul li { display: inline; float: right; padding: 3px; }

.slider { width: 800px; height: 350px; margin: 30px auto; display:; }

.slider img{ width: 800px; height: 350px; overflow: hidden; display: ; }

uh, could you wrap your code in the Markdown syntax for code? I don't see any HTML tags in your comment. There's a popup link for Markdown Cheatsheet that shows how to wrap code blocks.

I'm launching my site in Chrome.

Where do I find the pop-up link for wrapping code?

When you click "Add Comment", right below the text field where you write your comment, there's a sentence that says:

You can format your discussion with Markdown. If you aren't familiar with Markdown you can reference the Markdown Cheatsheet

Markdown Cheatsheet is an actual link that should open up a popup listing some commonly used Markdown syntax.

Another option to make your code viewable to others, would be to create a new Workspace and then share the link to the preview page.

1 Answer

You can't use an id AND a class in a selector. There is no need. Also, rename your id to something other than 1. Lets use #first-slider for example

An id is unique and can only be used once. So if you want to target only one slider use this:

$("#first-slider").hide("slow");

Your HTML should have an

id="first-slider"