在按键上显示隐藏div(视频)

时间:2016-05-15 18:08:54

标签: javascript html html5 toggle keypress

我在按键盘按钮时试图隐藏/显示视频,但无法使其正常工作

<script type="text/javascript" src="toggle.js"></script>
<div id="video">
  <video src="assets/knights.mp4" class="video" style="" id="video" loop="loop" muted="muted" autoplay="autoplay"></video>
</div>

togggle.js

$(document).keypress(function(e){
var key = e.which;
if (key == 116) {
    // if the user pressed 't':
    $('div').toggle();
}
});

0 个答案:

没有答案