-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
26 lines (24 loc) · 1.17 KB
/
main.js
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
// Set up for DOM content loaded event
addEventListener('DOMContentLoaded', () => {
// Declare const variables from ID card and icon element
const idCard = document.querySelector('.id-card');
const editIcon = document.querySelector('.edit-icon');
const saveIcon = document.querySelector('.save-icon');
function toggleEditMode() {
// Check if ID card has edit-mode class, hide save icon and display edit icon
// If not, then hide edit icon and display save icon
if (idCard.classList.contains('edit-mode')) {
idCard.classList.remove('edit-mode'); // remove ID card from edit mode
saveIcon.style.display = 'none'; // remove save icon
editIcon.style.display = 'block'; // display edit icon
}
else {
idCard.classList.add('edit-mode'); // put ID card is in edit mode
editIcon.style.display = 'none'; // remove edit icon
saveIcon.style.display = 'block'; // display save icon
}
}
// Call toggleEditMode function when icons are clicked
editIcon.addEventListener('click', toggleEditMode);
saveIcon.addEventListener('click', toggleEditMode);
});