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 trialhakan Gülay
8,489 Pointsı couldnt use jquery
Hi, ı want to use jQuery on sublime text 3 but it doesnt work! ı really dont know why. for example;
<!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">
</head>
<body>
<p class="warning">
<span>It's A Trap!</span>
</p>
<script src="http://code.jquery.com/jquery-1.11.0.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/app.js" type="text/javascript" charset="utf-8"></script>
</body>
</html>
that is code and
jQuery(".warning").hide();
this is other code. but It's A trap! doesnt disappear on page
5 Answers
hakan Gülay
8,489 Points<!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"> </head> <body> <p class="warning"> <span>It's A Trap!</span> </p>
<script src="http://code.jquery.com/jquery-1.11.0.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/app.js" type="text/javascript" charset="utf-8"></script>
</body> </html>
this is my code and other code for query jQuery(".warning").hide();
ı did it now.
ı removed "js/" from src="js/app.js" ı mean that became src="app.js" and it works now.
J Scott Erickson
11,883 PointsWithout knowing the structure of your page exactly this is my best suggestion
Note that the Javascript includes are at the bottom of the html:
<!Doctype html>
<html>
<head>
<!-- Your Css and Whatever else here -->
</head>
<body>
<div id="warning">
<!-- This is your stuff and whatever -->
</div>
<script src="http://code.jquery.com/jquery-1.11.0.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/app.js" type="text/javascript" charset="utf-8"></script>
</body>
</html>
js/app.js
$(".warning").hide();
// This Should hide it for ya.
hakan Gülay
8,489 Pointsgod why all code doesnt appear :) nvm ı should remove "js/" just but ı dont know why it works when ı remove it
J Scott Erickson
11,883 PointsThen your issue was that app.js was not in a folder named js
your file structure should have been like so:
index.html
js/ --> app.js
css/ --> something.css
While not required at all, this allow you to compartmentalize your files into coherent structures.
hakan Gülay
8,489 Pointsı got it and my last question is why we use this code for jquery
<script src="http://code.jquery.com/jquery-1.11.0.min.js" type="text/javascript" charset="utf-8"></script>
this code gets information from site ?
Bill Hinostroza
19,273 PointsWith this code you're telling the browser to grab the jQuery library from that source and with that you're able to use jQuery.
hakan Gülay
8,489 Pointsthank u guys ı understood now :)
Gard Mikael Fjeldavli
19,416 PointsGard Mikael Fjeldavli
19,416 Pointscould you paste all your html code?