Create Dark/Light Mode Using Javascript.

Create Dark/Light Mode Using Javascript.

DT

Code:-

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {Code:-
  padding: 25px;
  background-color: white;
  color: black;
  font-size: 25px;
}
.dark-mode {
  background-color: black;
  color: white;
}
</style>
</head>
<body>
<h2>Samir Dave</h2>
<p>Click the button to toggle between dark and light mode for this page.</p>
<button onclick="myFunction()">Dark mode</button>
<script>
function myFunction() {
   var element = document.body;
   element.classList.toggle("dark-mode");
}
</script>
</body>
</html>

Output:-


Thanks For Visit...

0 Comments