大家好,又见面了,我是全栈君,祝每个程序员都可以多学几门语言。
adjacent sibling combinator (+),当中
+的两側内容都是selector expression.
h1的直接兄弟元素h2
<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');
general sibling combinator (~)来实现
$('li.selected ~ li');
next().
var topHeaders = $('h1');
topHeaders.next('h2').css('margin', '0);
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/118822.html原文链接:https://javaforall.net
