Intro to Web Development
Copy doc
Make it interactive
Use JavaScript to make your website interactive

JavaScript (JS)

JavaScript
is a programming language that can add interactivity to your website. For example, you can use JavaScript to make things happen when the user clicks a button or enters information into a form.

The
<script>
tag

We will be writing our JavaScript in the
script.js
file. If you look at the
index.html
file, you'll see this line of code in the
<body>
element.
<
script
src
=
"script.js"
></
script
>

The
<script>
tag does the same job for JavaScript that the
<link>
tag does for CSS. It tells the browser to apply the code in script.js to the HTML file.

Note: Make sure the
<script>
comes right before the closing
</body>
tag! This ensures that the rest of the document elements have been loaded before the script is run.

⭐️ Step 0: Show an alert message

Programming crash course

For those of you who already know a programming language like Java or Python, feel free to skim this section or skip to the "Make your webpage interactive" section.

Variables

Data Types

Arrays

Functions

Conditionals

Loops

Make your webpage interactive

⭐️ Step 1: Access your HTML document

⭐️ Step 2: Access specific HTML elements

⭐️ Step 3: Add an event listener

🍦Challenge: Respond to user input

JavaScript Tasks
6
Task
Status
1
Show an alert message using JavaScript
Not Started
2
Access your HTML document using JavaScript
Not Started
3
Access specific HTML elements using JavaScript
Not Started
4
Add an event listener using JavaScript
Not Started
5
🍦Challenge: Respond to user input
Not Started
No results from filter

Next Section ➡️


Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.