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

JavaScript JavaScript Basics (Retired) Introducing JavaScript Where Does JavaScript Go?

My second and third alerts aren't working... why? (yes, I've checked quotes, etc.)

Why doesn't the second and third alerts work? (The first is in scripts.js) This is my code:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <link rel="stylesheet" href="css/main.css">
  <title>JavaScript Basics</title>
  <script src="scripts.js"></script>
  <script>
    alert("Here is another message");
  </script>
 </head>
<body>
  <div class="container">
    <h1>Where to place your js code.</h1>
    <script>alert("Here's a third message");</script>
  </div>
</body>
</html>

3 Answers

Raymond Osier
Raymond Osier
16,581 Points

your code is correct i copy and pasted your code and ran it in the browser it worked just fine , and no you do not have to define the scripting language in a script tag. the way your code is written is just fine.

luke hammer
luke hammer
25,513 Points

i believe that you have to define the scripting language in the script tag for that to work inline.

e.g. <script type="text/javascript">

thanks guys... I think I was having some browser issues.