Trying to make a message with the success of any operation. As a result, it turned out to make the message fly out in a second, but I can’t make the message delete after that, in the console it says that the function closing the window is not found, what's the problem?
btn = document.querySelector('button'); btn.addEventListener('click', function () { setTimeout('openWindow()', 1000); }) function openWindow() { document.querySelector('.window').style.display = 'block'; setTimeout('closeWindow()', 2000); function closeWindow() { document.querySelector('.window').style.display = 'none'; } } .wrapper { width: 600px; height: 400px; background-color: #21a1d7; position: relative; } .wrapper .window { width: 30%; position: absolute; height: 30px; background-color: green; right: 10px; top: 10px; text-align: center; color: white; display: none; } <div class="wrapper"> <button>Открыть окно</button> <div class="window"> Успешно! </div> </div>