Pac*_*cky 5 html javascript css jquery scope
当有人点击主导航链接时,我试图将一些jQuery挂钩到我的导航以淡入和退出页面包装器.代码本身工作正常,但只有2个问题:
任何帮助都会很棒.谢谢!!
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;
}
});
Run Code Online (Sandbox Code Playgroud)
导航的代码(使用wordpress)
<div id="nav_wrap">
<div id="nav"><?php wp_nav_menu( array( 'theme_location' => 'header-menu',) ); ?></div>
</div>
Run Code Online (Sandbox Code Playgroud)
HTML:
<div id="page-wrap" style="display: none;">
...
</div>
Run Code Online (Sandbox Code Playgroud)
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;
});
});
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10628 次 |
| 最近记录: |