このコードは、ロード時のブラウザのサイズに基づいてのみ機能します。現在のブラウザサイズを取得し、その現在の情報に基づいて機能するように実装できるかどうか疑問に思っています。
ラップしてみましresize()
たが、トグルが連続してオン/オフになる、または縮小したブラウザにロードするとまったく機能しないなど、奇妙な動作が発生します。
フッターメニューが大画面では静的リンクであるが、小画面ではドロップメニューに変わるレスポンシブサイト。
var myWidth = 0, myHeight = 0;
if( typeof( window.innerWidth ) == 'number' ) {
//Non-IE
myWidth = window.innerWidth;
myHeight = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
//IE 6+ in 'standards compliant mode'
myWidth = document.documentElement.clientWidth;
myHeight = document.documentElement.clientHeight;
}
if(myWidth < 980) {
$("#footer h3").click(function () {
$(this).toggleClass("active");
$(this).parent().find("ul").slideToggle('medium');
});
}