Search code examples
jqueryvideo.js

How can I pause ALL videos (html5) at once?


// now pause all active videos
$('.vid').get(0).pause();
$('.vid').get(1).pause();
$('.vid').get(2).pause();

That's what I have right now, but it's less than ideal. I'm a bit tired, so I could be missing something obvious, but how can I just tell it do pause all instances of .vid class on the page?


Solution

  • Try

    $('.vid').each(function() {
        $(this).get(0).pause();
    });