So this is the code I have:
$('.showvideo').click(function(){ // removes 'show' class from all images that aren't 'vid'
showAll();
if($('.gallery li img').hasClass('video')){
$('.gallery li img').addClass('show').removeClass('hide');
}
else{
$('.gallery li img').addClass('hide').removeClass('show');
}
});
At the moment it adds the class ‘show’ to all the images within ‘container’, even though only two out of the six have the class ‘video’. How do I only add the class ‘show’ to only those images which have the class ‘video’?
You can add the video class to your individual selector to get just the items you want like this. Assuming the video class is on the img tag itself, it would work like this:
Or, a little more efficiently: