当使用jQuery克隆视频元素时,Firefox不会将视频静音。
JS:
$( document ).ready(function() {
var origin = $('.item-video');
var target = $('.clone');
origin.clone(true).appendTo(target);
origin.empty();fix
});
HTML:
<div class="item-video">
<video width="560" height="315" autoplay muted controls loop>
<source src="big-buck-bunny_trailer.webm" type="video/webm">
<!-- <source src="http://video.webmfiles.org/big-buck-bunny_trailer.webm" type="video/webm"> -->
</video>
<a href="yourpage.html" class="button-video"></a>
</div>
<div class="clone">
</div><div class="item-video">
<video width="560" height="315" autoplay muted controls loop>
<source src="big-buck-bunny_trailer.webm" type="video/webm">
<!-- <source src="http://video.webmfiles.org/big-buck-bunny_trailer.webm" type="video/webm"> -->
</video>
<a href="yourpage.html" class="button-video"></a>
</div>
<div class="clone">
</div>
我有什么想法修复 Firefox上的错误
答案 0 :(得分:1)
我不知道为什么会在FF上发生这种情况,但这是解决方法
origin.clone(true).appendTo(target).find('video').attr('onloadedmetadata','this.muted =true');