var parent = document.getElementById("parent").children;
for (var i = 0; i < parent.length; i++) {
var m = Math.floor((Math.random() * 300) + 100);
console.log(m);
parent[i].style.margin = m+'px 0 0 0';
}
#parent div {
display: block;
height: 200px;
width: 200px;
text-align: center;
vertical-align: middle;
font-size: 100px;
background-color: black;
color: white;
}
<div id="parent">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
</div>
how can i tell if i scrolled on top of one of the child divs?
i tried using
parent.onscroll = function(){
... ... ...
}
but it does not work at all because it does not tell if scrolled on the children or not