I have a click function set for a video slider gallery, when i click the main video play / or pause I am trying to add a class "active--thumbnail" to the corresponding thumbnail. It is working and adding the class. When I click the main video again it is not removing the class. Not sure where I am going wrong here, any advice?
jquery:
$('.video-main').on('click', function () {
var mainVideoIndex = $('.video-main').index(this),
activeThumbnail = $(this).closest('.video-playlist').find('.l-thumbnail__title').eq(mainVideoIndex),
$('.l-thumbnail__title').not(activeThumbnail).removeClass('active--thumbnail');
activeThumbnail.addClass('active--thumbnail');
});
activeThumbnail.addClass('active--thumbnail');so when clicking on the same thumb as you previously did, will not remove the active class. You need to check if the clicked element already has active or not and do what you need