【问题标题】:Binding the timeupdate event with a div将 timeupdate 事件与 div 绑定
【发布时间】:2017-02-02 12:58:38
【问题描述】:

尝试使用 timeupdate 事件获取 ID 为 #banner 的 div,以便在视频播放 3 秒时显示。然后我希望它在视频播放 6 秒后淡出。到目前为止,这是我的代码,但我无法让它工作..

HTML:

<body>
<div id="banner">Win!</div>
<div id="container">
    <header>    
        <h1>Backin' Up</h1>
    </header>
<section>
<div class="videoWrapper">
    <video id="video2" controls>
        <source src="videos/wotebackinupsong.mp4">
        <source src="videos/wotebackinupsong.ogv">
    </video>
</div>

等等……

jQuery:

$('#video2').bind('timeudpate', function() {
var playTime = Math.round( $(this).get(0).currentTime );
    if(playTime == 3) {
        $('#banner').fadeIn(200);
    }
    if(playTime == 6) {
        $('#banner').fadeOut(200);
    }
});

谢谢!

【问题讨论】:

  • 你的视频在哪里?
  • 我在视频代码里加了

标签: jquery html events binding


【解决方案1】:

您的代码中有错字(“更新”):

$('#video2').bind('timeudpate', function() {

改成如下应该就ok了:

$('#video2').bind('timeupdate', function() {

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-10-09
    • 2013-05-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-05
    • 2015-10-01
    相关资源
    最近更新 更多