skip to Main Content

Javascript – How can I select HTML elements which are rendered after DOM

I want to select OKBTN let main = document.querySelector("#main"); let okBtn = document.querySelector("#ok"); function myAlert(title,msg,icon){ let card = ""; card += `<div class="card"> <img src="${icon}.jpg"> <h1>${title}</h1> <p>${msg}</p> <button id="ok">OK</button> </div>`; main.innerHTML = card; } okBtn.addEventListener("click", function(){ main.style.display = "none"; });…

VIEW QUESTION
Back To Top
Search