Как изменить отображаемую картинку в модальном окне?
Имеем, модальное окно, которое зависит от результата true || false. в нем пока 2 аргумента, время и boolean отвечающий за текст сообщения. нужно еще в зависимости от результата заменить иконку.
function showModal(formattedTime, gameResult) {
const modal = document.getElementById('myModal2')
modal.style.display = 'block'
const modalTimeElement = modal.querySelector('.window__fin_time')
modalTimeElement.textContent = formattedTime
const modalTextElement = modal.querySelector('.window__fin_text')
modalTextElement.textContent = gameResult ? 'Вы выиграли!' : 'Вы проиграли!'
........тут надо что-то написать)
}
<div id="myModal2" class="window__fin center modal">
<div class="window__fin_game">
<div class="window__fin_game2">
<span class="window__fin_imgwin">ТУТ ДОЛЖНЫ БЫТЬ КАРТИНКА</span>
<div class="window__fin_">
<p class="window__fin_text">Вы выиграли!</p>
</div>
<div class="window__fin_">
<p class="window__fin_text2">Затраченное время</p>
</div>
<div class="window__fin_">
<p class="window__fin_time">00.12</p>
</div>
<button id="restart-button1" class="button button__again ">Играть снова</button>
</div>
</div>
</div>
Источник: Stack Overflow на русском