forked from Harshsngh07/Hacktoberfest2020
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Harshsngh07#229 from mahimasawant/master
switch to dark mode in JS
- Loading branch information
Showing
4 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>My Webpage</title> | ||
<link rel="stylesheet" href="style.css" /> | ||
</head> | ||
|
||
<h1>My Webpage</h1> | ||
<div id="welcome"></div> | ||
<h4 id="time"></h4> | ||
|
||
<button id="btn" onclick="dark()">switch to dark mode</button> | ||
|
||
<script src="webpage.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
body { | ||
padding: 25px; | ||
background-color: white; | ||
color: black; | ||
font-size: 25px; | ||
} | ||
|
||
.dark-mode { | ||
background-color: black; | ||
color: white; | ||
} | ||
#btn { | ||
border-radius: 12px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
var name = prompt("Please enter your name"); | ||
|
||
if (name != null) { | ||
document.getElementById("welcome").innerHTML = | ||
"Hello " + name + "! Welcome to my Webpage"; | ||
|
||
const ctime = document.getElementById("time"); | ||
|
||
function clock() { | ||
let date = new Date(); | ||
let time = date.toLocaleTimeString(); | ||
ctime.innerText = time; | ||
} | ||
|
||
// clock(); | ||
|
||
setInterval(clock, 1000); | ||
} | ||
function dark() { | ||
var element = document.body; | ||
element.classList.toggle("dark-mode"); | ||
} |