I made an each function that counts the images inside a div and I am trying to set the number of images counted inside the div as a data attribute for the div but it is not working.
Have I gone about this the wrong way because it does not seem to be working?
Here is the site http://www.touchmarketing.co.nz/test/
var mostImages = 0;
numSliders = $wowSlides.length,
lastVindex = numSliders-1;
$wowSlides.each(function(){
var $this = $(this),
$images = $this.find('img'),
numImages = $images.length;
$images.css({width:$slideWidth, 'float':'left', 'position':'relative'}).wrapAll('<div class="slider" />');
$slider = $this.find(".slider");
$slider.width($slideWidth*numImages).css({'float':'left'});
$this.data('count', numImages); // add data-count="insert number here" to this .wowSlides div
console.log(numImages);
if(numImages > mostImages){
mostImages = numImages;
}
});
.data()on an element via jQuery will not show asdata-attributes in the source.