ページ内アンカーリンクがIE11で、クリックしても動作しません。。
console.logでは、#aboutなど取得できている様子です。
./#about などしたらリンクは動作しますが、アニメーションせず。
どなたかお分かりの方、ご教授下さい。。
よろしくお願い致します。
HTML
1<ul> 2<li><a href="#about">アバウト</a></li> 3<li><a href="#outline">概要</a></li> 4<li><a href="#event">イベント</a></li> 5<li><a href="#timeschedule">タイムスケジュール</a></li> 6<li><a href="#access">アクセス</a></li> 7</ul> 8 9<section id="about" class="element_section about"> 10・・・ 11</section>
javascript
1 $('a[href^="#"]:not(".event_item")').on('click', function(){ 2 //デフォルトのイベントをキャンセル 3 event.preventDefault(); 4 5 var target = $(this.hash); 6 console.log(this.hash); 7 console.log(target); 8 if (!target.length) return; 9 10 var navHeight; 11 if (window.matchMedia('(min-width:769px)').matches) { 12 navHeight = 67; 13 } else if (window.matchMedia('(max-width:768px)').matches) { 14 navHeight = 0; 15 } 16 var targetY = target.offset().top - navHeight; 17 18 $('body').animate({scrollTop: targetY}, 500, 'swing'); 19 });
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。