JavaScript How to increment margin value (or any style value) for each element using javascript?

You can try use method getComputedStyle,

The Window.getComputedStyle() method gives the values of all the CSS properties of an element after applying the active stylesheets and resolving any basic computation those values may contain.

because element.style.marginLeft does not show styles that come from CSS rules.

function MarginLeftFunc() {
  var elements = document.getElementsByClassName('divClass');
  var i, marginLeft = 70;

  for (i = 0; i < elements.length; i++) {
    marginLeft += parseInt(window.getComputedStyle(elements[i]).marginLeft, 10) + 70;
    elements[i].style.marginLeft = marginLeft + 'px';
  }
}

window.addEventListener('load', MarginLeftFunc, false);
.divClass {
  margin-left: 10px;
}
<div class="container">
  <div class="divClass">Div1</div>
  <div class="divClass">Div2</div>
  <div class="divClass">Div3</div>
</div>
Answer:1

How do I delete the created object "bird" from an array by name ie by the keyword "bird"? var storage = [ {cat: {name: "Garfild", count: 3443, price: 1000}} ]; function addProduct(...

How do I delete the created object "bird" from an array by name ie by the keyword "bird"? var storage = [ {cat: {name: "Garfild", count: 3443, price: 1000}} ]; function addProduct(...

If I create a inner class in a constructor, does it allocate memeory for each instance of the outer class that I create? For example, class PriorityQueue { constructor(maxSize) { // Set default ...

If I create a inner class in a constructor, does it allocate memeory for each instance of the outer class that I create? For example, class PriorityQueue { constructor(maxSize) { // Set default ...

I've come across this snippet and I have no idea why it does what it does. Try to answer the question yourself before looking at my answer below the code: what number will this alert? var foo = 1; ...

I've come across this snippet and I have no idea why it does what it does. Try to answer the question yourself before looking at my answer below the code: what number will this alert? var foo = 1; ...

How to get value from DB to the on-change event? Here is the example $("#widgetpanel").html(' >data="http://localhost:8080/guest?key='+$(this).val()+'item=??">'); I'm getting key from the drop-...

How to get value from DB to the on-change event? Here is the example $("#widgetpanel").html(' >data="http://localhost:8080/guest?key='+$(this).val()+'item=??">'); I'm getting key from the drop-...

  1. value change from
  2. value change dump
  3. value change management
  4. value chain analysis
  5. value change angular
  6. value change jquery
  7. value change listener java
  8. value change event