当用户点击允许用户跳过视频的跳过按钮
时,我尝试结束
视频。
我一直在使用以下内容,这一切都很好,并且允许我在视频结束时触发操作。
HTML
<video autoplay>
<source src="video.mp4" type="video/mp4">
</video>
<button class="skip">Skip video</button>
JS
$('video').on('ended',function(){....
//do stuff here
}
但是,我想做类似以下的事情,但不知道如何实现。
$('.skip').click(function(){
$('video').end();
});
最佳答案
end()
jQuery 中的方法用于返回到上一个选择器。
来自 jQuery 文档的描述:
<小时/>End the most recent filtering operation in the current chain and return the set of matched elements to its previous state.
要停止视频,请获取 dom 对象,然后使用 HTMLMediaElement#pause
方法。虽然最终使用 trigger()
以编程方式触发 ending
事件方法。
$('.skip').click(function(){
$('video').trigger('ended')[0].pause();
});
关于javascript - 单击时手动停止/跳过视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41673095/