Skip to content

Commit

Permalink
Update Magic.html
Browse files Browse the repository at this point in the history
  • Loading branch information
JPtheDash authored Mar 13, 2024
1 parent fc764a8 commit e0ee3fb
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions Magic.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@
<body>

<script>
var isVisible = true; // Variable to track the visibility state

document.addEventListener('click', function(event) {
if (isVisible) {
// If the image is visible, hide it
document.querySelectorAll('.multiplied-image').forEach(function(img) {
// Get the click coordinates
var x = event.clientX;
var y = event.clientY;

// Check if there are visible images
var visibleImages = document.querySelectorAll('.multiplied-image:not([style*="display: none"])');

if (visibleImages.length > 0) {
// If there are visible images, hide them
visibleImages.forEach(function(img) {
img.style.display = 'none';
});
} else {
// If the image is hidden, show it
// Get the click coordinates
var x = event.clientX;
var y = event.clientY;

// Create a new image element
// If no images are visible, create a new image at the click coordinates
var img = document.createElement('img');
img.src = 'egg.jpg'; // Replace 'image.jpg' with your image file path
img.className = 'multiplied-image';
Expand All @@ -41,9 +41,6 @@
// Append the image to the document body
document.body.appendChild(img);
}

// Toggle the visibility state
isVisible = !isVisible;
});
</script>

Expand Down

0 comments on commit e0ee3fb

Please sign in to comment.