2
jqueryを初めて使用しています。私は非常に多くの日のためのjqueryのナビゲーションに取り組んで、それは今うまく動作しますが、私はそれに多くの機能を追加したい。Jquery Accordion複数レベルのナビゲーション
3段階のネストされたアコーディオンナビゲーションがあり、バックグラウンドカラーを適用してどのセクションにいるのかをユーザーに知らせたいので、バックグラウンドカラーを最後のレベル私はまた、親のレベルに異なる背景色を適用することができます。ここ
<div id="accordion">
<h3><a>Link One - First Level</a></h3>
<div class="accordionSecond">
<h6><a href="#">Second Level</a></h6>
<div class="accordionLink">
<a href="1.html">1.html</a>
<a href="2.html">2.html</a>
<a href="3.html">3.html</a>
<a href="4.html">4.html</a>
</div>
</div>
<h3><a>Link Two - First Level</a></h3>
<div class="accordionSecond">
<h6><a href="#">Second Level</a></h6>
<div class="accordionLink">
<a href="1.html">1.html</a>
<a href="2.html">2.html</a>
<a href="3.html">3.html</a>
<a href="4.html">4.html</a>
</div>
</div>
</div>
彼らは
.accordionSecond .activeLink { background: #ccc; color:#000!important; }
jqueryのヘッダコード上にあるレベルに背景色を適用するCSSのラインは、ここで
<script>
$(document).ready(function() {
$("#accordion").accordion({active: true, collapsible: true, header: "h3", autoHeight: false, navigation: true, event: 'mouseup'});
$(".accordionSecond").accordion({active: true, collapsible: true, header: "h6", autoHeight: false, navigation: true,event: 'mouseup'});
});
</script>
<script type="text/javascript">
$(document).ready(function(){
var path = location.pathname;
jQuery("a[href$='" + path + "']").addClass("activeLink");
});
ありさのおかげ
おかげさまTom、もう1つの質問 –
私はクラスを追加しようとしましたが、それをクリックするとすべてのヘッダーにクラスが追加されます。私はこの方法が働いているとは思わない。 –
新しいコードで質問を編集してみてください。あなたが 'this'要素を選択していないようです –