if(window.location.hash) { var hash = window.location.hash.substring(1); //Puts hash in variable, and removes the # character if(hash == "welcome"){ document.getElementById("confetti").innerHTML = ""; } // hash found } else { // No hash found }