I currently have 7 different elements, each with unique margin-left and margin-top properties set in the CSS file. I am looking to loop through these elements and gather information about their margins.
This is what my jQuery code looks like so far:
var $elements = $(".elements");
var elementsMargins = [];
$elements.each(function(index){
var elementObj = {
elIndex: index,
elMarginLeft: this.css("margin-left"),
elMarginTop: this.css("margin-top")
};
elementsMargins.push(elementObj);
});
Unfortunately, I am encountering an issue where I am unable to retrieve these values. Can anyone provide advice or suggestions on how to resolve this problem?