8

我无法触发视频播放和暂停事件。我正在尝试:

<script type="text/javascript">
    $(function(){
        $(document).delegate('#play','click',function(){
            $('.video')[0].play();
        });
        $(document).delegate('#video-close','click',function(){
            $('.video')[0].pause();
        });
    });
</script>

<div class="video centered-content">
    <a class="circle-canvas close-video" href="javascript:void(0)" id="video-close">X</a>
    <video width="63%" height="80%" id="ourvideo" controls>
        <source src="http://videos.mozilla.org/serv/webmademovies/popcornplug.mp4">
        <source src="http://videos.mozilla.org/serv/webmademovies/popcornplug.ogv">
        <source src="http://videos.mozilla.org/serv/webmademovies/popcornplug.webm">
    </video>
</div>
<a class="circle-canvas close-video" href="javascript:void(0)" id="play" >play</a>

有什么建议吗?

4

1 回答 1

19

您正在选择没有play/pause方法的 div 元素。改变:

$('.video')[0].play(); 

到:

$('#ourvideo')[0].play(); 
于 2013-01-05T23:20:52.083 回答