在播放当前视频时暂停页面上的所有视频
pause all videos on page while current one is playing
我在页面上有多个 html5 个视频元素
当播放其中一个时,我需要暂停所有其他
这是我的尝试:
$('.player').on('play', function(){
console.log('playing'); // this works
$('.player').not($(this)).pause();
});
并出现控制台错误:
$(...).not(...).pause is not a function
有什么帮助吗?
.pause()
是一个 DOM 函数,而不是 jQuery 函数。尝试:
$('.player').not($(this)).trigger('pause');
我在页面上有多个 html5 个视频元素
当播放其中一个时,我需要暂停所有其他
这是我的尝试:
$('.player').on('play', function(){
console.log('playing'); // this works
$('.player').not($(this)).pause();
});
并出现控制台错误:
$(...).not(...).pause is not a function
有什么帮助吗?
.pause()
是一个 DOM 函数,而不是 jQuery 函数。尝试:
$('.player').not($(this)).trigger('pause');