JQuery 点击显示时自动播放视频

发布于 2024-11-18 13:14:43 字数 593 浏览 3 评论 0原文

我在导航面板上使用 JQuery,该面板的操作方式是单击以显示/隐藏。在“关于”面板上有一个小的 html5 视频,我想在点击显示时自动启动并在点击隐藏时停止视频。 “关于”面板的 ID 是:

<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;
});
});

非常感谢您的帮助。

安德里亚

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">

Sample code for how the panels function:

$(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;
});
});

Thanks you so much for your help.

Andrea

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

千纸鹤带着心事 2024-11-25 13:14:43

请参阅此:
http://www.w3.org/TR/html5/video.html#video

和控件属性:
http://www.w3.org/TR/html5/video .html#attr-media-controls

可能媒体方法“.play()”和“.pause()”会帮助你

这样的事情:

var video = $("#myvideo")[0]; // id or class of your <video> tag
if (video.paused) {
    video.play();
}    

“[0]”是获取html元素而不是一个 jQuery 对象。

See this:
http://www.w3.org/TR/html5/video.html#video

and the controls attribute:
http://www.w3.org/TR/html5/video.html#attr-media-controls

probably the media methods ".play()" and ".pause()" will help you

Something like this:

var video = $("#myvideo")[0]; // id or class of your <video> tag
if (video.paused) {
    video.play();
}    

the "[0]" is to get the html element instead of a jQuery object.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文