点击显示JQuery自动播放视频 [英] JQuery autoplay video on click show
问题描述
我在导航面板上使用JQuery,该面板按单击显示/隐藏。在关于面板上是一个小的html5视频,我想在点击显示时自动启动并在点击隐藏时停止视频。
关于面板的ID为:
I'm using JQuery on a navigational panel that operates as click to show/hide. On the "About" panel is small html5 video that I would like to auto start on click-show and stop video on click-hide. The id for the "About" panel is:
<div class="panel2">
面板功能的示例代码:
$(document).ready(function(){
$(".triggerso").click(function(){
$(this).hide();
$(".panelso").show("fast");
$('.panelso').click(function(){
$(this).hide();
$('.triggerso').show("fast"); });
$(".panel").hide("slow");
$(".panel1").hide("slow");
$(".panel2").hide("slow");
$(".panel3").hide("slow");
return false;
});
});
非常感谢你的帮助。
Andrea
推荐答案
请参阅:
http://www.w3.org/TR/html5/video.html#video
和controls属性:
http://www.w3.org/TR/html5/video.html#attr-media-controls
and the controls attribute:
http://www.w3.org/TR/html5/video.html#attr-media-controls
可能是媒体方法.play()和.pause()会帮助你
probably the media methods ".play()" and ".pause()" will help you
这样的事情:
var video = $("#myvideo")[0]; // id or class of your <video> tag
if (video.paused) {
video.play();
}
[0]是获取html元素而不是jQuery对象。
the "[0]" is to get the html element instead of a jQuery object.
这篇关于点击显示JQuery自动播放视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!