Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS How to make these actions flexible (Jquery) Re: How to make these actions flexible (Jquery)

#138555
CrocoDillon
Participant

You can make a global click listener like this:

$(‘#gallery_section’).on(‘click’, ‘.gallery_content’, function() {
// do stuff
});

then you can add more content even after document load. I’d go with some easier way to parse the data you need, instead of _one, _two etc (for example use `data-src` attribute). You don’t need all the images in the `#image_container`, you can just change the src attribute.

HTML:

`

`

jQuery:

$(‘#gallery_section’).on(‘click’, ‘.gallery_content’, function() {
$(‘#image_container > img’).attr(‘src’, $(this).data(‘src’));
});