Skip to content

Commit

Permalink
modified popup.js
Browse files Browse the repository at this point in the history
  • Loading branch information
j0ell1 committed Oct 14, 2024
1 parent defcb1b commit 4b2cf75
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ const icon = document.getElementById('infoIcon');
const popup = document.getElementById('popupInfo');

// Show popup when clicking on the icon
icon.addEventListener('click', () => {
icon.addEventListener('click', (e) => {
e.stopPropagation(); // Prevents the click from triggering the window event
popup.style.display = 'block';
});

// Hide popup when clicking outside
// Hide popup when clicking outside the popup or icon
window.addEventListener('click', (e) => {
if (e.target !== icon && !popup.contains(e.target)) {
if (!popup.contains(e.target) && e.target !== icon && !icon.contains(e.target)) {
popup.style.display = 'none';
}
});
});

// Prevent closing the popup when clicking inside it
popup.addEventListener('click', (e) => {
e.stopPropagation(); // Prevents closing the popup when clicking inside it
});

0 comments on commit 4b2cf75

Please sign in to comment.