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

Henry Miller
Henry Miller
7,945 Points

I have have to take my <script> tags out of the <div> in order fro my program to run. Why?

Here is a snapshot of my code:

https://w.trhou.se/ga38bsj53g

Please look at the HTML. This program runs. However, when I place the <script> inside of the <div> it stops running and doesn't get past the first console log. I am using the latest version of Chrome.

1 Answer

You should not place your script inside the div in the first place, it should go just before the body closing tag, your js file should explain where and when it is running; not your html.

hope that helps.

Henry Miller
Henry Miller
7,945 Points

It was just that in the video, his Java statements were populating within the <div> I guess it just confused me. Thanks!