2016-03-21 51 views
0

當播放視頻時,我想隱藏我的頁面導航,就像播放按鈕一樣。 下面是成功地隱藏了播放按鈕的腳本:當視頻播放時隱藏不相關的div

<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

回答

0

嘗試使用jQuery .toggle()函數;

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

你沒有關閉功能, if語句

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

+0

嗯,仍然不起作用。我有可憐的知識 –