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
Tom Pickles
787 PointsGetting held up trying to learn jQuery
I'm doing examples from the Headstart books (keep opinions to yourself please), and for reasons I cannot figure out, the examples are unresponsive on clicks, etc.
I get the feeling my script tags are in the wrong place? Or maybe I'm not using the proper version of jQuery? So confused. Codepen below.
Thanks.
4 Answers
John Locke
15,479 PointsTom:
$(document).ready(function(){
$("#clickMe").click(function() {
$('img').fadeIn(1000);
$('#picframe').slideToggle("slow");
});
});
no closing tag on 'img' , and the curly braces go inside of the parentheses.
Tom Pickles
787 PointsThanks, but that button is still unresponsive....
Tom Pickles
787 PointsFigured it out. Didn't have a downloaded version of jQuery in a folder that held the CSS and HTML. Right?
John Locke
15,479 PointsOn Codepen, you can just toggle the latest version of jQuery (or other JavaScript libraries) on and off under the JS section. That's what I did.
Tom Pickles
787 PointsWhile we're at it...why won't this work?
http://codepen.io/anon/pen/pLGcB
I'm not understanding why nothing's happening. This code is straight copy and pasted from the book, so there shouldn't be any errors.
John Locke
15,479 PointsIf you move the CSS and JS into the appropriate sections on Codepen, it works just fine. Be sure to delete the comments in the Javascript if you move it over.
Tom Pickles
787 PointsMoved everything over and deleted comments...still unresponsive for me.
http://cdpn.io/pLGcB (with changes).
John Locke
15,479 PointsIf you click on the button in the bottom left, Edit This Pen, it works over there. Have you tried this in a regular browser?
Derrick Mull
18,518 PointsLooking at this in Chrome, I found it unresponsive in both full and edit views.
Using <script src="scripts/jquery-1.6.2.min.js"></script> to pull down jquery won't work on codepen because you are not physically storing the jquery library at that location on the site.
2 options:
1) Use a CDN to pull down jquery, like <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
2) use the jquery library available if you click the cog beside JS over the javascript editor in codepen.
Derrick Mull
18,518 Pointsof course, the CDN was escaped, lets try this again:
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
John Locke
15,479 PointsI can't remember if I mentioned it to Tom previously, that gear icon in the top right of the JS let's you load JavaScript libraries, including the latest version of jQuery. Using the sections on code pen for HTML, CSS, and JavaScript, I was able to make his pen work, but I had to separate out the pieces.