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
Mark Bradshaw
Courses Plus Student 7,658 PointsI'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>
Mark Bradshaw
Courses Plus Student 7,658 PointsI 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: ; }
wuworkshop
3,429 Pointsuh, 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.
Mark Bradshaw
Courses Plus Student 7,658 PointsI'm launching my site in Chrome.
Mark Bradshaw
Courses Plus Student 7,658 PointsWhere do I find the pop-up link for wrapping code?
wuworkshop
3,429 PointsWhen 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.
wuworkshop
3,429 PointsAnother 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
jaredcowan
11,808 PointsYou 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"
wuworkshop
3,429 Pointswuworkshop
3,429 PointsCould 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#1is valid selector. Try just.sliderwithout the #1 part at the end.