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 trialjonathan amador
Full Stack JavaScript Techdegree Student 6,154 Pointsthis about the challenger 1 :"Move the script tag where it'll get executed after the page loads."
Should I delete the script? or create a variable ?
<!DOCTYPE html>
<html lang="en">
<head>
<title> JavaScript Foundations: Variables</title>
<style>
html {
background: #FAFAFA;
font-family: sans-serif;
}
</style>
<script src="myscript.js"></script>
</head>
<body>
<h1 id="title">JavaScript Foundations</h1>
<h2>Variables: Basics</h2>
<div id="container">
This is a div with the id of "container"
</div>
</body>
</html>
/* JavaScript Foundations: Variables */
var bgColor = "";
var textColor = "";
var container = document.getElementById('title');
container.style.background = bgColor;
container.style.color = textColor;
2 Answers
Colin Bell
29,679 PointsIt is asking you to move the script tag that is in the head to a place in the document where the <script> tag will load after all html content has loaded.
You don't have to do anything with the myscript.js file yet. All you have to do is move the script tags.
<!DOCTYPE html>
<html lang="en">
<head>
<title> JavaScript Foundations: Variables</title>
<style>
html {
background: #FAFAFA;
font-family: sans-serif;
}
</style>
/*This script tag will try to load BEFORE all other content.
Move it somewhere that will force it to load AFTER all other content has loaded */
<script src="myscript.js"></script>
</head>
<body>
<h1 id="title">JavaScript Foundations</h1>
<h2>Variables: Basics</h2>
<div id="container">
This is a div with the id of "container"
</div>
</body>
</html>
jonathan amador
Full Stack JavaScript Techdegree Student 6,154 Pointsthanks , cool now undestand, thanks Colin
Colin Bell
29,679 PointsAwesome. Glad I could help.
jonathan amador
Full Stack JavaScript Techdegree Student 6,154 Pointsjonathan amador
Full Stack JavaScript Techdegree Student 6,154 PointsThanks for your help Colin ...
Tanya Bushnell
181 PointsTanya Bushnell
181 PointsThanks for the help / hint, Colin!