Home › Forums › CSS › How to make these actions flexible (Jquery) › Re: How to make these actions flexible (Jquery)
June 13, 2013 at 3:41 am
#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’));
});