我有一个网站,在主页上有一种介绍导航。选择选项时,会出现一个导航栏。当我点击“主页”时,我需要它再次隐藏。第一段代码工作正常。下半场我遇到了麻烦:
//Show navbar on page scroll
$(window).bind('scroll', function() {
$("nav").fadeIn(1400);
var navSeen = true;
});
//Hide navbar if #home is clicked
$("#home").click(function(){
$("nav").fadeOut(1400);
var navSeen = false;
});
提前感谢您的帮助!
编辑——文件中的所有 JS:
<script type="text/javascript">
$(document).ready(function(){
////////////////////////////////
//Lock Dog in place when scrolling right
var dogLock = $('#dog').position().left;
$(window).scroll(function() {
if(dogLock >= $(window).scrollLeft()) {
if($('#dog').hasClass('leftLock')) {
$('#dog').removeClass('leftLock');
}
} else {
if(!$('#dog').hasClass('leftLock')) {
$('#dog').addClass('leftLock');
}
}
});
//If the connect tab is open and you click outside, then exit out of it!
var menu_state_ = true;
$('#connect').click( function(e) {
e.preventDefault();
if (menu_state_up){
menu_state_Down();
} else {
menu_state_Up();
}
return false;
});
$('html').click(function() {
menu_state_Up();
});
function menu_state_Down() {
$("#connect-window").fadeIn(200);
menu_state_up = false;
}
function menu_state_Up() {
$("#connect-window").fadeOut(200);
menu_state_up =true;
}
//Ease into each transition
$(function() {
$('.link').bind('click',function(event){
var $anchor = $(this);
$('html, body').stop().animate({
scrollLeft: $($anchor.attr('href')).offset().left - 300
},600,'easeInOutExpo');
event.preventDefault();
});
});
//Big Text Plugin
$('.intro').bigtext();
//If the page has scrolled then display the hidden menu
$(window).bind('scroll', function() {
$("nav").fadeIn(1400);
var navSeen = true;
});
//Hide navbar if #home is clicked
$("#home").click(function() {
$("nav").fadeOut(1400);
var navSeen = false;
});
//////////////////////////////////////////
});
</script>