<div>
<h1>Main title</h1>
<h2>Section title</h2>
<p>Some content...</p>
<h2>Section title</h2>
<p>More content...</p>
</div>$('h1 + h2')
// Select ALL h2 elements that are adjacent siblings of H1 elements.
$('h1').siblings('h2,h3,p');
// Select all H2, H3, and P elements that are siblings of H1 elements.
nextAll()<ul>
<li>First item</li>
<li class="selected">Second Item</li>
<li>Third item</li>
<li>Fourth item</li>
<li>Fifth item</li>
</ul>如果要获取第二个条目之后的所有li元素,可以使用如下代码
$('li.selected').nextAll('li');
$('li.selected ~ li');
next().
var topHeaders = $('h1');
topHeaders.next('h2').css('margin', '0);
jQuery -> 获取兄弟元素,布布扣,bubuko.com
原文地址:http://blog.csdn.net/feelang/article/details/26605035