JavaScript – Change the Margin of Div
To change the margin of a div using JavaScript, get reference to the div element, and assign required margin value to the element.style.margin
property.
Example
Conclusion
In this JavaScript Tutorial, we learned how to change the margin of a div using JavaScript.