-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
26 lines (24 loc) · 714 Bytes
/
Copy pathmain.js
File metadata and controls
26 lines (24 loc) · 714 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
const toggleDialog = () => {
// Get the dialog element
const dialog = document.getElementById("dialog");
// Figure out what the 'open' attribute is set to
const open = dialog.getAttribute("open");
// Set the dialog's 'open' value accordingly
if (open) {
dialog.removeAttribute("open");
} else {
dialog.setAttribute("open", "true");
}
};
const openModal = () => {
// Get the modal element
const modal = document.getElementById("modal");
// Call the built-in 'showModal' method to display the modal
modal.showModal();
};
const closeModal = () => {
// Get the modal element
const modal = document.getElementById("modal");
// Call the built-in 'close' method to close the modal
modal.close();
};