-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsinglepage0.html
46 lines (42 loc) · 1.25 KB
/
singlepage0.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<!DOCTYPE html>
<html lang="en">
<head>
<title>Single Page</title>
<style>
div {
display: none;
}
</style>
<script>
function showPage(page) {
// Hide all other pages
document.querySelectorAll('div').forEach(div => {
div.style.display = 'none';
});
// Show requested page
document.querySelector(`#${page}`).style.display = 'block';
}
document.addEventListener('DOMContentLoaded', function() {
document.querySelectorAll('button').forEach(button => {
button.onclick = function() {
showPage(this.dataset.page);
};
});
});
</script>
</head>
<body>
<button data-page="page1">Page 1</button>
<button data-page="page2">Page 2</button>
<button data-page="page3">Page 3</button>
<div id="page1">
<h1>This is page 1.</h1>
</div>
<div id="page2">
<h1>This is page 2.</h1>
</div>
<div id="page3">
<h1>This is page 3.</h1>
</div>
</body>
</html>