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
Marty Kunsman
Full Stack JavaScript Techdegree Graduate 22,262 PointsMy first website with Javascript
Hi yall, I can't seem to get my first website to see the JS file. I will include the index.html and the js file below. Thanks much, Marty
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Supine Twist Massage Therapists </title>
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400;300' rel='stylesheet' type='text/css'>
<link href='style.css' rel='stylesheet'>
<link rel="stylesheet" href="CSS/normalize.css">
<link href='http://fonts.googleapis.com/css?family=Jockey+One|Open+Sans:400italic,700italic,400,700,800' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="CSS/main.css">
<link rel="stylesheet" href="CSS/responsive.css">
<meta name="viewport" content="width=device-width, initial-scale= 1.0"> <!-- If we don't add this the desktop layout will be put on mobile devices -->
</head> <body> <header>
<h1 class="company-name">Supine Twist</h1>
<h2>Massage Therapists</h2>
<h3>5200 Park Road</h3>
<h3 id="city">Charlotte, NC 28209</h3>
<!-- <nav> <ul> <li><a href="index.html" class="selected">Portfolio</a></li> <li><a href="about.html">About</a></li> <li><a href="contact.html">Contact</a></li> </ul> </nav> --> </header> <div id="choose"> <section> <h2>Are you in need of massage therapy?</h2> <h3>Choose Type</h3> <h3>Spa Massage</h3> <h3>Clinical Massage</h3> <img src="img/massage-photo1.jpg" alt="Photo of Massage Session" class = "massage-photo1">
</section>
<footer>
<a href="http://nytimes.com"><img src="Img/twitter-wrap.png" alt="Twitter Logo" class="social-icon"></a>
<a href="http://foxsports.com"><img src="Img/facebook-wrap.png" alt="Facebook Logo" class="social-icon"></a>
<p>© 2014 Marty Kunsman.</p>
</footer>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="app.js"></script>
</body>
</html>
app.js
var main = function() { console.log("testing"); };
$(document).ready(main);
5 Answers
Julian Aramburu
11,368 PointsHi Martin! The problem here is on your call to google's JQuery in your script tag. You forgot to add the https: at the beginning !
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
Julian Aramburu
11,368 PointsIs your app.js file in the same folder than your index file? Because you are targeting "app.js" as it was. If app.js is in a different folder you must target it like this : src="folder_name/file.js" ...I tested your code and it works if you target the files properly so it must be the problem here.
Marty Kunsman
Full Stack JavaScript Techdegree Graduate 22,262 PointsI set it up so that index,html, about.html, contact.html and app.js are not in folders. I only created folder for CSS and Images. Thanks, Marty
Julian Aramburu
11,368 PointsIt's weird ...are you sure it doesn't print out anything in the console? Because I'm testing it right now and even changing the output in the console.log() statement , it prints whatever I want. and I'm using the same script tags you wrote there. I'll copy you a snapshot of what I'm doing:
Marty Kunsman
Full Stack JavaScript Techdegree Graduate 22,262 PointsNo, I'm not getting that console.log statement. Is there any other way of testing it? Maybe I don't fully understand the console.log.
Julian Aramburu
11,368 PointsBut are you accessing the console? Ctrl + shift + J on PC and Cmd + Opt + J on MAC. I mean, we are using the same code...it should work the same way. Unless you are using some really really old browser.
Marty Kunsman
Full Stack JavaScript Techdegree Graduate 22,262 PointsOk, thanks, I didn't know how to load the console. Now I see these errors. I'm gonna take these statements out because I'm not using them. I'll let you know.... Marty
Uncaught SyntaxError: Unexpected token } http://port-80-qlrzjreybg.treehouse-app.com/Img/facebook-wrap.png Failed to load resource: the server responded with a status of 404 (Not Found) http://port-80-qlrzjreybg.treehouse-app.com/Img/twitter-wrap.png Failed to load resource: the server responded with a status of 404 (Not Found)
Marty Kunsman
Full Stack JavaScript Techdegree Graduate 22,262 PointsHey, I got it....it was an extra curly bracket in my javascript causing this error. It was cool the way the console told me the error was in the js.....I was getting tired of checking the css. Appreciate the help. Marty
Julian Aramburu
11,368 PointsGlad you got it :)! Keep coding!
Marty Kunsman
Full Stack JavaScript Techdegree Graduate 22,262 PointsMarty Kunsman
Full Stack JavaScript Techdegree Graduate 22,262 PointsHi, thanks for your help. I changed the code but I'm still not seeing my console.log statement. This is all pretty new to me. Thanks, Marty
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script src="app.js"></script> </body>
</html>