0

私は 4 つの Jquery タブを持っています。各タブには 2 つのビデオがあります。一度に 1 つのビデオを再生し、他のすべてのビデオを一時停止するにはどうすればよいですか? 新しいタブに切り替えたときにビデオを一時停止するにはどうすればよいですか?

これはコードJsfiddleです

/* play one video at a time */

$('video').bind('play', function() {
  activated = this;
  $('video').each(function() {
      if(this != activated) {
          this.pause();
      }
  });
});

/* get the active tab */
var active = $( "#issuestabs" ).tabs( "option", "active" ); 


/* pause all videos that are not in the active tab*/ 

if (!active) {
    $("video").each(function(){
        $(this).get(0).pause();
    });

}

誰が何が間違っているのか教えてもらえますか?

ありがとう!

4

1 に答える 1

2

使える:

$('.tab').on('click', function() {
  $('.tabcontent:hidden').find('video').each(function() {
    $(this).get(0).pause();
  });
});

(.tabcontentは非表示/表示されているコンテンツ パネルの名前です。タブに使用しているライブラリがわからないため、表示されたクリック機能は単なる例です。)

于 2013-08-23T15:41:09.447 に答える