Is it possible to dynamically change the position of multiple div
elements on a webpage without reloading?
I am looking for a way to modify the top and left positions of several div
s, all with the same class, simultaneously. I want each div
to have a different position without having to refresh the page.
For example:
.class{
background-color:black;
color: white;
position:absolute;
top: RANDOM;
left: RANDOM;
}
<div1 class="class"></div> /// positioned at top:100px and left:200px
<div2 class="class"></div> /// positioned at top:245px and left:298px
<div3 class="class"></div> /// positioned at top:190px and left:490px
<div4 class="class"></div> /// positioned at top:89px and left:344px
Is there a way to achieve this on the same page? I have looked for solutions but only found scripts that change the position of one div upon clicking, not multiple divs simultaneously.