I try to move a div(#ball) inside another the div(#square) to click point by Javascript. The first click would move #ball without transition duration 1s. But from second click things work normally until I refresh the Html page.
I use a new Chrome browser.
Html
<div class="" id="square">
<div class="" id="ball" ></div>
</div>
CSS
#square {
/*background-color, width etc */
position: relative;
}
#ball {
/*background-color, width etc */
position: absolute;
transition-duration: 1s;
}
Javascript
let square = document.getElementById('square');
let ball = document.getElementById('ball');
square.addEventListener('click', (event) => {
ball.style.top = event.pageY + "px";
ball.style.left = event.pageX + "px";
});