JSFiddle - React, Tailwind, and code Playground
HTML
<div class="goods">
<div class="product"></div>
<div class="product"></div>
<div class="product"></div>
<div class="product"></div>
<div class="product"></div>
<div class="product"></div>
<div class="product"></div>
</div>
CSS
.goods {
display: flex;
flex-wrap: wrap;
}
.product {
width: 200px;
height: 100px;
margin: 10px;
background: #d4d4d4;
}
.active {
border: 2px solid red;
}
JavaScript
const goods = document.querySelectorAll('.product')
var coun = 0;
function activeItem() {
this.classList.toggle('active')
}
let launchInterval = function (time) {
var fun = setInterval(function(){
activeItem.call(goods[coun++])
ŃlearInterval(fun)
},400)
return setInterval(function() {
console.log('super')
});
};
let id = launchInterval(400);
clearInteval(id);
id = launchInterval(400);