I am trying to grab the attributes on certain selection tags like so:
$('tagName').swapper();
Each section has like data-image="source", I need to grab each of these and create an array out of it. Here is where I am stuck, I can get each one individually, but not all at once to create the array, below is my code for the array creation.
var imgArray = [];
$this.each(function() {
var count = getImgAttr.length;
imgArray.push([getImgAttr]);
console.log(imgArray);
console.log(count);
});
getImgAttr is just $this.data("image");
This returns each one as an individual array, not one combined.
How would I connect all of them and prevent them from being split?
Thanks guys.
[]? you should be defining getImgAttr for each image you are iterating over, otherwise it will only ever look at the first image.