это будет считаться, как правонарушением прав или чего-либо?
Есть 3 блока, которые хранятся в массиве
let block = document.querySelectorAll(".block");
const index = Array.prototype.indexOf.call(block, e.target);const index = [...block].findIndex(n => n === e.target);let index = block.length;
while (index-- > 0 && block[index] !== e.target) ;
color.bind(null, i) надо сохранить - в какой-нибудь массив, например.let wrap = document.querySelector('.wrap');
wrap.onclick = ()=> wrap.classList.toggle('noMagic');.wrap{
position: relative;
width: 500px;
height: 200px;
background: lightblue;
margin: 0 auto;
}
.wrap::before{
position: absolute;
content: 'Кликни на меня, детка!';
height: 50px;
width: 100%;
background: lightgreen;
transition: 2s;
}
.noMagic.wrap::before{
content: 'А ты молодец!';
display: flex;
justify-content: center;
align-items: center;
animation: move 1s forwards;
}
@keyFrames move{
100% {
height: 100%;
}
}
forEachWithDelay(
document.querySelectorAll('.x'),
1000,
el => el.style.display = 'block'
);function forEachWithDelay(arr, delay, callback) {
Array.prototype.forEach.call(arr, (n, i) => {
setTimeout(callback, (i + 1) * delay, n);
});
}function forEachWithDelay(arr, delay, callback) {
(function next(i) {
if (i < arr.length) {
setTimeout(() => {
callback(arr[i]);
next(-~i);
}, delay);
}
})(0);
}function forEachWithDelay(arr, delay, callback) {
let i = -1;
const intervalId = setInterval(() => {
if (++i < arr.length) {
callback(arr[i]);
} else {
clearInterval(intervalId);
}
}, delay);
}