console
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>project1</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="emojiOpen active">
<img src="https://www.pinclipart.com/picdir/middle/536-5360426_monkey-face-emoji-clipart-monkey-emoji-png-download.png" alt="">
</div>
<div class="emojiClosed">
<img src="https://www.emoji.co.uk/files/emoji-one/animals-nature-emoji-one/1468-see-no-evil-monkey.png" alt="">
</div>
<script>
const closedFace=document.querySelector('.emojiClosed');
const openFace=document.querySelector('.emojiOpen');
openFace.addEventListener('click',()=>{
if(closedFace.classList.contains('emojiClosed')){
closedFace.classList.add('active');
openFace.classList.remove('active');
}
})
closedFace.addEventListener('click',()=>{
if(openFace.classList.contains('emojiOpen')){
openFace.classList.add('active');
closedFace.classList.remove('active');
}
})
</script>
</body>
</html>
*{
box-sizing: border-box;
margin: 0;
padding: 0;
}
body{
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
}
img{
height: 512px;
width: 512px;
cursor: pointer;
}
.emojiClosed{
display: none;
}
.emojiOpen{
display: none;
}
.active{
display: block;
}