在视频播放时隐藏不相关的div

时间:2016-03-21 15:29:53

标签: html video hide playing

我想在播放视频时隐藏我的页面导航,就像播放按钮一样。 这是成功隐藏播放按钮的脚本:

<script>
$('.vid').parent().click(function () {
if($(this).children(".vid").get(0).paused){
$(this).children(".vid").get(0).play();
$(this).children(".playpause").fadeOut();
}else{
$(this).children(".vid").get(0).pause();
$(this).children(".playpause").fadeIn();
}
});
</script>

这个脚本我试图隐藏我的导航栏:

<script>
function vidplay() {
var video = document.getElementById(".vid");
var button = document.getElementById(".playpause");
if (video.paused) {
video.play();
$(".navbar").hide();
</script>    

Here's link to my site

2 个答案:

答案 0 :(得分:0)

你没有关闭你的功能和if语句

&#13;
&#13;
<script>
function vidplay() {
  var video = document.getElementById(".vid");
  var button = document.getElementById(".playpause");
  if (video.paused) {
    video.play();
    $(".navbar").hide();
  }
}
</script>    
&#13;
&#13;
&#13;

答案 1 :(得分:0)

尝试使用jQuery .toggle()函数;

$('.vid').parent().click(function () {
    $(".navbar").toggle();
});