0

我试图在一些动态生成的内容中使用 end 作为视频标签,但它不起作用,我知道为什么,这是我的代码。

$(document).ready(function() { 
$('.container').on('click','.videobox',function(){
    var $this = $(this);
    var video = $this.next('video')[0];
    if (video.paused) {
        $this.css({
            opacity: 0
        });
        video.play();
    } else {
        video.pause();
        $this.css({
            opacity: 0.5
        });
    }

}).on("ended",".test",function () { alert('asd');
    $(this).prev('.videobox').css({
        opacity: 0.5
    });
});
});

这是html

<div class="videobox" style="position: absolute; z-index: 500; background-color: #000; opacity: 0.5; width: 473px; height: 474px;"><img src="/image/camera.png" style="position: relative; top: 45%; margin-left: 160px;"></div>
<video class="test" width="473" height="474">
  <source src="stuff.mp4" type="video/mp4">
  <source src="movie.ogg" type="video/ogg">
  Your browser does not support the video tag.
</video>
4

0 回答 0