Event Handlers
Putting your CSS and JS in separate files.
Starting with this example:
Move the JS to a separate file called script.js
:
What happens if...?
Put the
<script>
tag before the<div>
Put it after the
div
Put it in the
<head>
Keep it in the
<head>
and adddefer
to the tag - this is what we want to do going forward.
Show that we can also add stylesheets by linking them with the <link>
tag (demo with a background color or something).
Textboxes!
Extend the kitten example to use a textbox to do input.
Introducing input boxes with
<input type="text">
Using
.value
to get the value of the text box in JavaScript
index.html
script.js
References
Last updated
Was this helpful?