onclick没有调用函数

时间:2019-12-23 19:22:23

标签: javascript html css function

我正在尝试制作一个覆盖整个屏幕的按钮,该按钮是充当背景的视频,单击该按钮应该会暂停视频。

即使光标在“标记”(不可见的)按钮上并且我的代码似乎正确(显然不是),也没有任何反应。

ERROR [23000] [Sybase][ODBC Driver][SQL Anywhere]Constraint 'ASA6532' violated: Invalid value in table 'emp_def'

1 个答案:

答案 0 :(得分:0)

在这里有效。不知道出了什么问题。

var video = document.getElementById("myVideo");
function stopVideo() {
    video.pause();
}
<!DOCTYPE html>
<html>
    <head>
        <style>
            html, body { margin: 0; padding: 0; width: 100%; height: 100%; }
            #button { width: 100%; height: 100%; opacity: 0; cursor: pointer; }
            #myVideo { position: fixed; right: 0; bottom: 0; min-width: 100%; min-height: 100%; }
        </style>
    </head>
    <body>
        <video autoplay loop muted id="myVideo">
            <source src="https://www.sample-videos.com/video123/mp4/720/big_buck_bunny_720p_2mb.mp4" type="video/mp4">
        </video>
        <button id="button" type="button" onclick="stopVideo()"></button>
    </body>
</html>