-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
29 lines (26 loc) · 904 Bytes
/
index.html
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
27
28
29
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Dynamically load style sheet</title>
<link rel="stylesheet" href="css/main.css">
<link id="theme-link" rel="stylesheet" href="css/day.css">
</head>
<body>
<header>
<input type="radio" id="day-theme" name="theme" checked>Day theme</a>
<input type="radio" id="night-theme" name="theme">Night theme</a>
</header>
<main>
<div>Hello world!</div>
</main>
<script type="text/javascript">
document.querySelectorAll("input[name='theme']").forEach((input) => { input.addEventListener('change', setStyleSheetHref); });
function setStyleSheetHref(event)
{
document.getElementById('theme-link').setAttribute('href', event.target.id == 'day-theme' ? 'css/day.css' : 'css/night.css');
}
</script>
</body>
</html>