Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

dark mode html css javascript

<!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>

Comment

dark mode javascript

// Enter code directly in the console for instant dark mode.
var allDivs = document.querySelectorAll('div');

for(var i = 0; i < allDivs.length; i++){
  allDivs[i].style['background-color'] = 'black';
  allDivs[i].style['color'] = 'green';
  allDivs[i].style['font-family'] = 'Monospace';
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: even numbers in an array 
Javascript :: javascript regex get domain from url 
Javascript :: JSON parse error: Cannot deserialize value of type `java.util.Date` from String 
Javascript :: fetch not working javascript 
Javascript :: dual array javascript 
Javascript :: how to refrence schema in my mongoose schema 
Javascript :: set route on button in angular 
Javascript :: LEAODE MAJE 
Javascript :: jquery direct window print pdf 
Javascript :: using settings_data.json shopify 
Javascript :: socket io stream 
Javascript :: is js dead 
Javascript :: array for numbers 
Javascript :: how to create a web browser in javascript 
Javascript :: "npm supertest 
Python :: jupyter ignore warnings 
Python :: pandas read tsv 
Python :: number table python 
Python :: show all columns in pandas 
Python :: Import "reportlab.pdfgen.canvas" could not be resolved 
Python :: extract year from datetime pandas 
Python :: pandas create empty dataframe 
Python :: python print traceback from exception 
Python :: how to check python version 
Python :: ctrl c exception python 
Python :: NAN values count python 
Python :: flip a plot matplotlib 
Python :: python loop through all folders and subfolders 
Python :: add picture to jupyter notebook 
Python :: how to find geometric mean in python 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =