我有4个Jquery标签,在每个标签中有2个视频。如何同时播放一个视频并暂停其他所有视频?以及当我切换到新标签页时如何使视频暂停?
这是代码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();
});
}
谁能告诉我这是怎么回事?
谢谢!
您可以使用:
$('.tab').on('click', function() {
$('.tabcontent:hidden').find('video').each(function() {
$(this).get(0).pause();
});
});
(.tabcontent
隐藏/显示的内容面板的名称在哪里,我显示的单击功能只是一个示例,因为我不知道您要使用哪个库来制作标签。)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句