I am trying to hook some jQuery to my nav to fade in and out the page wrapper when someone click on a main nav link. The code itself is working fine, but just have 2 issues:
Any help would be great. Thanks!!
JS
$(document).ready(function() {
$('#page-wrap').css('display', 'none');
$('#page-wrap').delay(500).fadeIn(1000);
$('.menu-item').click(function(event) {
event.preventDefault();
newLocation = this.href;
$('#page-wrap').fadeOut(1000, newpage);
});
function newpage() {
window.location = newLocation;
}
});
The code for the Nav (using wordpress)
<div id="nav_wrap">
<div id="nav"><?php wp_nav_menu( array( 'theme_location' => 'header-menu',) ); ?></div>
</div>
HTML:
<div id="page-wrap" style="display: none;">
...
</div>
jQuery:
$(document).ready(function() {
$('#page-wrap').delay(500).fadeIn(1000);
$('.menu-item').click(function(event) {
event.preventDefault();
var newLocation = this.href;
$('#page-wrap').fadeOut(1000, function () {
window.location = newLocation;
});
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With