// Get all elements with class="closebtn"varclose=document.getElementsByClassName("closebtn");vari;// Loop through all close buttonsfor(i=0;i<close.length;i++){// When someone clicks on a close buttonclose[i].onclick=function(){// Get the parent of <span class="closebtn"> (<div class="alert">)vardiv=this.parentElement;// Set the opacity of div to 0 (transparent)div.style.opacity="0";// Hide the div after 600ms (the same amount of milliseconds it takes to fade out)setTimeout(function(){div.style.display="none";},600);}}