let c=document.querySelector(".imge");
c.addEventListener("dragstart",()=>{setTimeout(()=>{c.classList.add("hide")},0)})
.hide{
display: none;
}
<img src="https://picsum.photos/200/300" draggable="true" class="imge" alt="" height="100px">
without setTimeout when i run this code and drag the image i dont see the dragged image. But with it image hides but i still see the dragged image. can you explain what settimeout is doing and why this is happening?