<li class="page_item "><a href="javascript:">A</a>
<ul class="children">
<li class="page_item"><a href="javascript:">1</a></li>
<li class="page_item"><a href="javascript:">2</a></li>
</ul>
</li>
<li class="page_item "><a href="javascript:">B</a>
<ul class="children">
<li class="page_item"><a href="javascript:">1</a></li>
<li class="page_item"><a href="javascript:">2</a></li>
<li class="page_item"><a href="javascript:">3</a></li>
<li class="page_item"><a href="javascript:">4</a></li>
</ul>
</li>
$('.children a').click(function(event){
event.stopPropagation();
$('ul.children').prev().css('background','red');
});
在线示例:http: //jsfiddle.net/uybPf/
我想实现当我点击A或B的子菜单时,A或B就会高亮显示。但我的代码突出显示了所有这些。我不想使用toggleClass()
请有人帮忙修复我的代码。谢谢