Last active
January 31, 2025 20:31
-
-
Save hmowais/767cbac83c48a57f029cf9f6ecd9fdb2 to your computer and use it in GitHub Desktop.
Important Videos Link
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Dynamic Popup content from custom post type | |
https://www.youtube.com/watch?v=9lMGc1fQa3Q&pp=ygUnRHluYW1pYyBQb3N0IFBvcHVwIFdpZGdldCBmb3IgRWxlbWVudG9y | |
<style> | |
.container { | |
display: none; /* Hide all containers by default */ | |
} | |
.button_style { | |
pointer-events: auto; | |
cursor: pointer; /* Ensure pointer cursor on hover */ | |
} | |
</style> | |
<script> | |
document.addEventListener('DOMContentLoaded', function () { | |
// Select all buttons that have an ID starting with 'button' | |
const buttons = document.querySelectorAll('[id^=button]'); | |
// Add event listeners to each button | |
buttons.forEach(button => { | |
button.addEventListener('click', function () { | |
const postID = button.id.replace('button', ''); // Extract the post ID from the button ID | |
const containerID = 'container' + postID; // Construct the container ID | |
// Hide all containers | |
document.querySelectorAll('.container').forEach(container => { | |
container.style.display = 'none'; | |
}); | |
// Show the specific container related to the clicked button | |
const containerToShow = document.getElementById(containerID); | |
if (containerToShow) { | |
containerToShow.style.display = 'block'; | |
} | |
}); | |
}); | |
// Add event listener to each close icon | |
document.querySelectorAll('.close-icon').forEach(icon => { | |
icon.addEventListener('click', function () { | |
// Hide all containers when a close icon is clicked | |
document.querySelectorAll('.container').forEach(container => { | |
container.style.display = 'none'; | |
}); | |
}); | |
}); | |
}); | |
</script> | |
// Dynamic Popup End |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment