HTML and JavaScript, Day 5: Baby JavaScript
2025-09-17
Days 1-2:
<h1>, <p>, <em>, <strong>, <a>, <img>, <ul>, <li>href and alt<head>, <nav>, <main>, <section>, <footer>Days 3-4:
<footer> code. Before we typed “2025”.<span id="year"></span> is the code that is giving us the correct value<script><script>
const yearSpan = document.getElementById("year");
yearSpan.textContent = new Date().getFullYear();
</script><script><script>
const yearSpan = document.getElementById("year");
yearSpan.textContent = new Date().getFullYear();
</script>const is one way that JS defines a variableconst)year is that name that we give to the variable; Span is required in calling up that variable in our script
cookie, nananananana, whatever!nananananana?<script><script>
const yearSpan = document.getElementById("year");
yearSpan.textContent = new Date().getFullYear();
</script>document.getElementById("year")
<span> inside the footer.yearSpan.<script><script>
const yearSpan = document.getElementById("year");
yearSpan.textContent = new Date().getFullYear();
</script>new Date()
.getFullYear()
yearSpan.textContent = new Date().getFullYear();
<span>.firstname_lastname.html doc<footer><script>
<body>, right before </body><!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
padding: 25px;
background-color: white;
color: black;
font-size: 25px;
}
.dark-mode {
background-color: black;
color: white;
}
</style>
</head>
<body>
<h2>Toggle Dark/Light Mode</h2>
<p>Click the button to toggle between dark and light mode for this page.</p>
<button onclick="myFunction()">Toggle dark mode</button>
<script>
function myFunction() {
var element = document.body;
element.classList.toggle("dark-mode");
}
</script>
</body>
</html>function) is doing.