title: add data to element in each function
body: <p>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.</p>
  
  <p>Have I gone about this the wrong way because it does not seem to be working?</p>
  
  <p>Here is the site <a href="http://www.touchmarketing.co.nz/test/" rel="noreferrer">http://www.touchmarketing.co.nz/test/</a> </p>
  
  <pre><code>    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('&lt;div class="slider" /&gt;');
          $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 &gt; mostImages){
  
              mostImages = numImages;
  
          }                   
  
      });
  </code></pre>