[英]Javascript mobile navigation menu
我正在關注在線Lynda.com教程,該教程通過Javascript和JQuery格式化移動導航菜單。 第一步是下載JQuery,將JQuery和Javascript掛接到我的HTML中,並用警報檢查該文檔,該方法可以正常工作,但是隨后我需要在下面鍵入代碼。但該功能不起作用。 任何人都可以在代碼中看到任何錯誤嗎? 謝謝。
/ * JavaScript文檔* /
$(document).ready(function(){
$('nav a.mobile_menu').on('click',function(){
var currentNavHeight = $('nav').height();
if( currentNavHeight < 5 ){
var newNavHeight = $('nav > ul').height() + 15;
$('nav').animate({'height':newNavHeight+'px'},750);
}else{
$('nav').animate({'height':'0px'},750,function(){
$(this).removeAttr('style');
});
}
});
$(window).resize(function(){
if( $(this).width() > 625 ){
$('nav').removeAttr('style');
}
});
除非提供的代碼示例不完整,否則您沒有$(window).resize
函數或包裝$(document).ready
函數的$(window).resize
括號。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.