How to prevent event bubbling in javascript
It is caused due to event bubbling.Triggering an event on child propagates upward toward its parent.In your case click event on image also triggers click event on parent div.use event.stopPropagation()
to prevent this from happening.
HTML :
pass the event
as parameter to event listener function
<img id="exit" onclick="hideCreations(event)" src="./assets/images/exit.png" alt="exit button" title="Leave Planet: Mercury" />
JS:
Capture the event and call it's stopPropagation method
function hideCreations(event){
event.stopPropagation()
document.getElementById("projects").style.display = "none";
}