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 trialAndrew Falkowski
708 PointsCan't get the javascript to execute.
For some reason I cannot get the javascript to execute, I have tried multiple different ways but I can't seem to get it to work. My code is pasted below, please help.
<script type="text/javascript" src="inductive-js/jquery.js"></script> <script type="text/javascript"> $(".qty").hide(); $(".order-now").click(function(){ var $link = $(this); $(link).next().show("slow"); return false; });
3 Answers
Tim Knight
28,888 PointsAndrew, check the part where you're assigning $(this)
to a variable of $link
, because you're doing that you'd reference the next line like
var $link = $(this);
$link.next().show("show");
Instead of with $(link)
use $link
which is the name of your variable.
George Cristian Manea
30,787 Pointsi think you should use link.next().show("slow")
because you already stored a jquery object in your link variable
Andrew Falkowski
708 PointsThanks a lot guys I got it to work!
George Cristian Manea
30,787 PointsGeorge Cristian Manea
30,787 PointsHey Tim can you tell me how can i write the code so it appears like yours?
Tim Knight
28,888 PointsTim Knight
28,888 PointsGeorge at the bottom of the comments textarea you'll see a "Markdown Cheatsheet", click that. It'll review how to do it for large code blocks.
George Cristian Manea
30,787 PointsGeorge Cristian Manea
30,787 PointsThank you, i didn't see it :)