0
有一個愚蠢的問題,只是想要在子菜單可見時將類添加到li a。它是級聯的,並將該類添加到所有li a,甚至是子菜單中的該類。當可見下拉菜單時,將類添加到父李a
<ul id="nav">
<li><a href="#" target="_self">HOME</a></li>
<li class="dropdown"><a href="#" target="_self">SYSTEM MANAGER<span aria-hidden="true" data-icon=""></span></a>
<ul>
<li><a href="#" target="_blank">Link 1</a></li>
</ul>
</li>
</ul>
JS
$('li.dropdown').on('mouseenter mouseleave', function(e){
e.preventDefault();
if (e.type === 'mouseenter')
$(this).addClass('hilight');
else
$(this).removeClass('hilight');
});
CSS
body header #headerContain nav#nav-wrap ul#nav li.dropdown.hilight a {
color: #db4105;
}
我如何得到它僅適用於父li.dropdown和沒有它級聯到孩子李一的?
D'哦。 thx男人,今天CPU時間太多。 – 2013-03-27 02:41:17
:)高興地幫助。 – ocanal 2013-03-27 02:41:51