I'm overlaying images on top of each other and want to make it so when you click each one it disappears, revealing the image underneath. This is what I have in the script tag:
function attach_eventhandler(d){
d.onclick = function(){
this.style.visibility = "hidden";
}
}
var myArray = document.getElementsByTagName("heart");
for(var d of myArray){
attach_eventhandler(d);
}
And these are the two images I have right now. I want "heart" to disappear, then "pig".
<img id="pig"src="pig.jpg" alt= height="700 px" width="500 px">
<img id="heart"src="heart.jpg" alt= height="700 px" width="500 px">