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 trialBen Goldman
14,626 PointsJQuery function not running
I have been racking my brain to figure out why my JQuery isn't running. The browser tools say that $(document) is undefined. It doesn't appear that .ready(myCode) is being loaded at all. As far as I can tell, I have copied the code exactly as it appears in the lesson.
<!DOCTYPE html>
<html>
<head>
<title>Take Evasive Action</title>
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" title="no title" charset="utf-8">
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="js/app.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<p class="warning">
<span>It's A Trap!</span>
</p>
<div class="image">
<img src="img/ackbar.gif" />
</div>
var myCode = function() {
$(".warning").hide().show("slow");
}
$(document).ready(myCode);
3 Answers
Ben Goldman
14,626 PointsProblem solved. Anyone else having issues with this project, or just curious, should visit this forum post and watch Andrew's video:
https://teamtreehouse.com/forum/jquery
Turns out there are technical issues with the "//" method of linking to JQuery. Very important info to know.
Tricia Martin
19,604 PointsDid you add the jQuery script file to the HTML page?
<!DOCTYPE html>
<html>
<head>
<title>Take Evasive Action</title>
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" title="no title" charset="utf-8">
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="js/app.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<p class="warning">
<span>It's A Trap!</span>
</p>
<div class="image">
<img src="img/ackbar.gif" />
</div>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="js/app.js" type="text/javascript" charset="utf-8"></script>
</body>
</html>
Ben Goldman
14,626 PointsYeah. Sorry, I just couldn't get it to render correctly to the forum.
Tricia Martin
19,604 PointsClick the link below labeled 'Markdown Cheatsheet' for tips on getting your code to render. Basically you just put three tick marks ( ` ) with no spaces before the first line of code and after the last line of code.
Ben Goldman
14,626 PointsThanks. Got it. I was using apostrophes.