Hello everyone!
I’m having a problem with my lightbox, when I click on an image, the lightbox doesn’t open (because I put the wrong class in addEventListener), the problem is, when I put the right class with the pictures and the videos (.media-card), I have an error message that tells me that addEventListener is null.
So I don’t know what to do because, the right class is null because the class is not detected and I need that to open my lightbox.
To clarify : My addEventListener is in another folder (photographerPage.js) than my lightbox (lightbox.js) and each pictures and videos have ID in a JSON folder
If you need more details don’t hesitate.
Thanks in advance.
GitHub Pages : FishEye - Profil photographe
addEventLister code (with the wrong class) :
document.querySelector(’.lightbox-media’).addEventListener(‘click’, () => {
console.log('test')
new Lightbox(
[
{
id: 5234343,
url: "resources/243/Resized_images/Animals_Wild_Horses_in_the_mountains.mp4"
},
{
id: 623534343,
url: "resources/243/Resized_images/Travel_Lonesome.jpg"
},
{
id: 625025343,
url: "resources/243/Resized_images/Travel_HillsideColor.jpg"
},
{
id: 23523434,
url: "resources/243/Resized_images/Event_BenevidesWedding.jpg"
},
{
id: 2523434634,
url: "resources/243/Resized_images/Portrait_Nora.jpg"
},
{
id: 95234343,
url: "resources/243/Resized_images/Animals_Rainbow.jpg"
},
{
id: 398847109,
url: "resources/243/Resized_images/Portrait_Background.jpg"
},
{
id: 65235234,
url: "resources/243/Resized_images/Event_PintoWedding.jpg"
},
{
id: 2525345343,
url: "resources/243/Resized_images/Portrait_Wednesday.jpg"
},
{
id: 2534342,
url: "resources/243/Resized_images/Event_SeasideWedding.jpg"
}
],
1
)
})