-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
114 lines (94 loc) · 3.07 KB
/
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<!DOCTYPE html>
<html lang="en">
<style>
.container {
margin: 40px auto;
width: 80%;
}
.button {
width: 160px;
height: 45px;
border-radius: 6px;
font-size: 15px;
margin-top: 20px;
}
img {
width: 328px;
height: 287px;
display: block;
margin-bottom: 20px;
}
hr {
width: 400px;
margin-left: 0;
}
h3 {
display: inline-block;
}
#container {
display: none;
}
#container-edit {
display: none;
}
#container-edit input {
height: 32px;
}
#container-edit hr {
margin: 25px 0;
}
#container-edit input {
width: 195px;
font-size: 15px;
}
</style>
<script>
function editProfile() {
document.querySelector('.container').style.display = 'none'
document.querySelector('.container-edit').style.display = 'block'
const name = document.querySelector('#name').textContent
document.querySelector('#input-name').value = name
const email = document.querySelector('#email').textContent
document.querySelector('#input-email').value = email
const interests = document.querySelector('#interests').textContent
document.querySelector('#input-interests').value = interests
}
function saveProfile() {
document.querySelector('#name').textContent = document.querySelector('#input-name').value
document.querySelector('#email').textContent = document.querySelector('#input-email').value
document.querySelector('#interests').textContent = document.querySelector('#input-interests').value
document.querySelector('.container').style.display = 'block'
document.querySelector('.container-edit').style.display = 'none'
}
</script>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div class='container'>
<h1 id='header'>User Profile</h1>
<img src='profile-picture'>
Name: <h3 id='name'>John Doe</h3>
<hr />
Email: <h3 id='email'>[email protected]</h3>
<hr />
Interests: <h3 id='interests'>coding</h3>
<hr />
<button class='button' onclick="editProfile()">Edit Profile</button>
</div>
<div class='container-edit'>
<h1 id='header'>User Profile</h1>
<img src='profile-picture'>
Name: <input id='input-name' type='text' />
<hr />
Email: <input id='input-email' type='email'>
<hr />
Interests: <input id='input-interests' type='text'>
<hr />
<button class='button' onclick="saveProfile()">Save Profile</button>
</div>
</body>
</html>