HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers60/vandeurzenheftrucks.nl/wwwroot/js/vandeurzen/imageSwapper.js
// Give all images an opacity of 50%
$('.images-thumbs img').css('opacity', 'none');

// Give the first loaded image an active class
$('.images-thumbs img:first-child').addClass('active');

// When someone clicks an image thumbnail
$('.images-thumbs img').on('click', function(){

    if($(this).hasClass('active')){
        // Do nothing
    }

    else{
        // Remove the active class from the current loaded image
        $('.images-thumbs').find('.active').removeClass('active');

        // Get the image url
        var imageUrl = $(this).attr('data-url');

        swapImage(imageUrl);

        $(this).addClass('active');

        // Function replaces the src attribute data with new image url
        function swapImage(url){
            var mainImage = $('.image-main img');
            mainImage.attr('src', url);
        }
    }

});