forked from swapnilsparsh/30DaysOfJavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
26 lines (25 loc) · 699 Bytes
/
script.js
File metadata and controls
26 lines (25 loc) · 699 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
$(document).ready(function () {
$(window).scroll(function () {
if ($(this).scrollTop() >= 100) {
$(".scrollToTop").fadeIn();
} else {
$(".scrollToTop").fadeOut();
}
});
$(".scrollToTop").click(function (e) {
e.preventDefault();
$("html, body").animate({ scrollTop: 0 }, 500);
return false;
});
});
function toggleDarkLight() {
var body = document.getElementById("body");
var button = document.getElementById("toggle");
if (button.innerHTML == "🌙") {
button.innerHTML = "☀️";
} else {
button.innerHTML = "🌙";
}
var currentClass = body.className;
body.className = currentClass == "dark-mode" ? "light-mode" : "dark-mode";
}