<button>
<img src="">
</button>
<style>
button {
max-width: 300px;
}
img {
max-width: 100%;
}
</style>
<script>
const allowedImages = [
'https://static.tildacdn.com/tild3739-3339-4864-b734-386336353235/20143010160217.jpg',
'https://static.ngs.ru/news/99/preview/6c6786496a5b02d55635825ce30ad55800531fc0_824_549_c.jpg',
'https://cs8.pikabu.ru/post_img/big/2016/12/28/1/1482881197192578721.jpg',
];
let currentImageIndex = -1;
const button = document.querySelector('button');
button.addEventListener('click', function () {
this.querySelector('img').src = allowedImages[++currentImageIndex % allowedImages.length];
});
button.dispatchEvent(new Event('click'));
</script>