I am trying to make a dark/light mode button in my project, but it is not working. Can anyone help me on the functions or how to call them? Thanks!
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>HTML CSS JavaScript Cheatsheet</title>
<!-- Load external CSS styles -->
<link rel="stylesheet" href="styles.css">
</head>
<header>
<div>
<img src="https://upload.wikimedia.org/wikipedia/commons/6/61/HTML5_logo_and_wordmark.svg" class="html logo">
<img src="https://upload.wikimedia.org/wikipedia/commons/d/d5/CSS3_logo_and_wordmark.svg" class="css logo">
<img src="https://upload.wikimedia.org/wikipedia/commons/d/d4/Javascript-shield.svg" class="js logo">
</div>
<nav>
<ul>
<li><a href="#html">HTML</a></li>
<li><a href="#css">CSS</a></li>
<li><a href="#js">JavaScript</a></li>
</ul>
</nav>
<button onclick="darkFull()">Toggle light/ dark mode</button>
</header>
<body>
<section role="region" aria-labelledby="html">
<h1>HTML Cheatsheet</h1>
<hr>
<h1 class="head">HEADINGS</h1>
<code><h1>Heading 1</h1></code>
<code><h2>Heading 2</h2></code>
<code><h3>Heading 3</h3></code>
<code><h4>Heading 4</h4></code>
<code><h5>Heading 5</h5></code>
<code class="last"><h6>Heading 6</h6></code>
</section>
<!-- Load external JavaScript -->
<script src="scripts.js"></script>
</body>
</html>
/* Place your CSS styles in this file */
*:not(code){
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}
h1, h2, h3, h4, h5, h6 {
text-align: center;
}
header > nav > ul > li {
justify-content: center;
display: block;
text-align: right;
font-size: large;
margin: 0 0.2rem;
padding: 0.2rem;
}
header {
background-color: #def;
color: #000;
text-align: right;
display: flex;
justify-content: space-between;
}
.logo {
height: 100px;
width: 100px;
}
header > nav > ul {
display: flex;
justify-content: space-evenly;
flex-wrap: wrap;
align-items: center;
padding-inline-start: 0;
margin-block: 0;
}
code {
font-size: 50px;
border: solid 5px #000;
border-style: solid solid none solid;
}
.last {
border-style: solid;
}
.head {
font-size: 75px;
margin: 0;
}
.dark-mode {
background-color: #000;
color: #fff;
}
body {
background-color: #fff;
color: #000
}
.dark-header {
background-color: #225;
color: #ff0;
}
/* Place your JavaScript in this file */
function darkFull() {
darkMode();
darkHeader();
}
function darkMode() {
var element = document.body;
element.classList.toggle("dark-mode");
}
function darkHeader() {
var element = document.header;
element.classList.toggle("darkHeader")
}