使用jQuery在10秒后播放视频
我想在10秒后播放视频。setTimeOut的功能似乎不起作用。 这是javascript函数:使用jQuery在10秒后播放视频,jquery,html,Jquery,Html,我想在10秒后播放视频。setTimeOut的功能似乎不起作用。 这是javascript函数: $('.top').toggle( 3000 ); $('.top1').delay(3000).toggle(3000); setTimeout(function(){ $(".video").play(); }, 6000); html部分: <video class="video" width="700" height="700"> <source src
$('.top').toggle( 3000 );
$('.top1').delay(3000).toggle(3000);
setTimeout(function(){
$(".video").play();
}, 6000);
html部分:
<video class="video" width="700" height="700">
<source src="images/video9.mp4" type="video/mp4">
<source src="imagesvideo9.ogg" type="video/ogg">
</video></div>
<img class="top" src="images/boot.png" style="display:none; hidden; position:absolute; left:-1%; top:8.5%;" width="710" />
<img class="top1" src="images/boot1.png" style="display:none; position:absolute; left:-1%; top:75%;" width="710"/>
方法在HTMLVideoElement上,而不是jQuery对象上。试试这个:
setTimeout(function(){
$(".video")[0].play(); // note the [0] to access the native element
}, 10000); // 10 seconds = 10000 ms
你能详细说明什么东西不起作用吗?