jQuery .next() gets the immediately following sibling of each element in the set of matched elements; Also check jQuery .prev();
<script>
$('.target').next()
.css('background-color', 'yellow')
.append(' <span class="label label-info">next after .target</span>');
$('li').next('.target')
.css('background-color', 'yellow')
.append(' <span class="label">next with .target class</span>');
</script> |
<script>
$('.target').next()
.css('background-color', 'yellow')
.append(' <span class="label label-info">next after .target</span>');
$('li').next('.target')
.css('background-color', 'yellow')
.append(' <span class="label">next with .target class</span>');
</script>
<ul>
<li>list item
<ul>
<li>list item</li>
<li class="target">list item with target class</li>
<li>list item</li>
<li>list item</li>
</ul>
</li>
<li>list item</li>
<li class="target">list item with target class</li>
<li>list item</li>
<li>list item</li>
</ul> |
<ul>
<li>list item
<ul>
<li>list item</li>
<li class="target">list item with target class</li>
<li>list item</li>
<li>list item</li>
</ul>
</li>
<li>list item</li>
<li class="target">list item with target class</li>
<li>list item</li>
<li>list item</li>
</ul>