jqueryfroogaloop

jQuery sending only the first character of string with each() and this


I'm trying to call Froogaloop for various iframes on a single page, but this is returning only the first character of the playerID ('vimeo1', 'vimeo2', etc.)

I log playerId (a string) immediately before each() and it returns fine, but as soon as I get inside each(), this becomes "v".

jQuery(playerId).each(function(){
  Froogaloop(this).addEvent('ready', ready);
});

Thanks!


Solution

  • Are you referencing an element on the page with playerID? Is "vimeo1" a class name or ID? If so, the string needs to be either .vimeo1 or #vimeo1. That way, jQuery will search for an element like jQuery('.vimeo1') instead of jQuery('vimeo1')

    var playerId = '.vimeo1';
    
    jQuery(playerId).each(function(){
      Froogaloop(this).addEvent('ready', ready);
    });