everyone,
I found a jquery code that changes the image onclick however, I would like to add/remove the class when it is clicked/active. I couldn't figure it out.
Thanks for helping in advance.
jQuery(document).ready(function ($) {
$('.black-button').on({
'click': function () {
$('#change-image').attr('src', 'https://images.unsplash.com/photo-1607180234730-7a5c833e6a8a?ixlib=rb-1.2.1&ixid=MXwxMjA3fDB8MHxwcm9maWxlLXBhZ2V8NXx8fGVufDB8fHw%3D&auto=format&fit=crop&w=500&q=60');
}
});
$('.red-button').on({
'click': function () {
$('#change-image').attr('src', 'https://images.unsplash.com/photo-1607348907250-691de1d47163?ixid=MXwxMjA3fDB8MHxwcm9maWxlLXBhZ2V8NHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60');
}
});
$('.blue-button').on({
'click': function () {
$('#change-image').attr('src', 'https://images.unsplash.com/photo-1607349153323-3290ed68d04d?ixid=MXwxMjA3fDB8MHxwcm9maWxlLXBhZ2V8Mnx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60');
}
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="button-container">
<button class="black-button">Berlin</button>
<button class="red-button">İstanbul</button>
<button class="blue-button">Sweden</button>
</div>
<img id="change-image" src="https://images.unsplash.com/photo-1607180234730-7a5c833e6a8a?ixlib=rb-1.2.1&ixid=MXwxMjA3fDB8MHxwcm9maWxlLXBhZ2V8NXx8fGVufDB8fHw%3D&auto=format&fit=crop&w=500&q=60" alt="">