jQuery:在活动的上方选择li

时间:2011-05-31 11:49:04

标签: javascript jquery list html-lists

如何将样式border-bottom : none;添加到位于有效<li>之上的<li>

<ul>
  <li>text</li> <!--this li must get the border-bottom : none then.-->
  <li class="active">text</li>
  <li>text</li>
</ul>

3 个答案:

答案 0 :(得分:3)

$('.active').prev('li').css('border-bottom','none');

答案 1 :(得分:3)

$('li.active').prev().css('border-bottom', 'none');

答案 2 :(得分:0)

您想要使用jQuery兄弟()。阅读本文,它很可能会对您有所帮助:http://api.jquery.com/siblings/

相关问题