I have this loop that produces many elements with different positions:
if ( $row['Type'] == "house") { ?>
<div class="itemW" style="margin-left: <?=$row['X']?>px; margin-top: <?=$row['Y']?>px;">
Item
</div> <?
}
I need to change all the divs left position, I’m trying this:
var items = document.getElementsByClassName("itemW");
items[0].style.left = land.width() / items[0].style.left * 100;
The problem is that items[0].style.left doesn’t get the position of the first div. Also I don’t know how to do it with all the divs.
You can get all elements with a particular class name with
for anything but IE < 9 at least 😛
Then it’s just a matter of looping through them like so