Aray Karjauv
Aray Karjauv

Reputation: 2945

Accessing Video.js player without ID

I have some <video> tags without ID on my page. I have to access them to set up some features. I've tried to use jQuery

$(function(){
  $('video').each(function(){ $(this)[0].player.play() }
});

but it seems that at this point videojs isn't initialized.

Is there any way to do this?

Upvotes: 1

Views: 1668

Answers (1)

misterben
misterben

Reputation: 7821

You can pass a video element as the argument to videojs() to create the player

$(function(){
  $('video').each(function(){
    videojs($(this)[0]).play();
  });
});

Upvotes: 3

Related Questions