Jak Klikając w container kolejno wykonać function one(), następnie po 2 kliknięciu function two() itd
var container=document.querySelector('.container');
var photo1=document.querySelector('.photo1');
var photo2=document.querySelector('.photo2');
var photo3=document.querySelector('.photo3');
function one(){
photo1.style.animation="leftphoto 1s forwards";
};
function two(){
photo2.style.animation="leftphoto 1s forwards";
};
function three(){
photo3.style.animation="leftphoto 1s forwards";
};
photo1.addEventListener('click',one,false);
photo2.addEventListener('click',two,false);
photo3.addEventListener('click',three,false);
function containerclick(){
container.addEventListener('click',one,false);
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body >
<div class="container" onclick="containerclick()">
<div class="photo1"></div>
<div class="photo2"></div>
<div class="photo3"></div>
</div>
.container{
width: 100%;
height: 100vh;
margin: 0 auto;
display: flex;
justify-content: center;
align-items: center;
}
.photo1,.photo2,.photo3{
position: absolute;
width: 40%;
height: 50vh;
margin: 0 auto;
display:block;
}
.photo1{
background-color: rgb(129, 118, 618);z-index: 3;transition: 1s cubic-bezier(0.075, 0.82, 0.165, 1);
}
.photo2{
background-color: red;z-index: 2;
}
.photo3{
background-color: yellow;z-index:1;
}
@keyframes leftphoto {
from{transform:translateX(0)}
to{transform: translate(100%);opacity:0;}
}