I want to move an element from top to bottom, adding 1px to its top every 10millisecond using setInterval
This is my code:
var cir1 = document.getElementsByClassName('cir1');
function moveCir(elem) {
var elemTop = elem.style.top + 'px';
elem.style.top = elemTop;
elem.style.top = elemTop + 1 + 'px' ;
setInterval(function () {
moveCir(elem)
},10)
}
.cir1 {
height: 100px;
width: 100px;
margin: 30px 100px;
border: 1px solid #AC0D67;
border-radius: 100%;
display: inline-block;
}
<button onclick="moveCir(cir1)" id="start">Start</button>
<div class="cir1"></div>
But I cant find out why its not working