jQuery nextAll until the following class -
so i'm trying assign .subs
previous div
able assign 1 go after preceding div
.
i can't figure out how assign .subs
after .right
until next .right
here example idea
$(".right").each(function() { var = $(this).find('ul li:last-child'); $(this).next('.subs').insertafter(a); });
.right { border: 1px solid #000; padding: 10px margin-bottom: 10px }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <div class="right"> <ul> <li>one</li> <li>two</li> </ul> </div> <div class="subs"> <div class="right"> <ul> <li>subs one</li> <li>subs two</li> </ul> </div> </div> <div class="subs"> <div class="right"> <ul> <li>subs one</li> <li>subs two</li> </ul> </div> </div> <div class="right"> <ul> <li>one</li> <li>two</li> </ul> </div> <div class="right"> <ul> <li>one</li> <li>two</li> </ul> </div> <div class="subs"> <div class="right"> <ul> <li>subs one</li> <li>subs two</li> </ul> </div> </div>
i think .nextuntil()
you're looking for. returns following siblings to, not including, element matches selector.
$(".right").each(function() { var = $(this).find('ul li:last-child'); $(this).nextuntil('.right').insertafter(a); });
.right { border: 1px solid #000; padding: 10px margin-bottom: 10px }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <div class="right"> <ul> <li>one</li> <li>two</li> </ul> </div> <div class="subs"> <div class="right"> <ul> <li>subs one</li> <li>subs two</li> </ul> </div> </div> <div class="subs"> <div class="right"> <ul> <li>subs one</li> <li>subs two</li> </ul> </div> </div> <div class="right"> <ul> <li>one</li> <li>two</li> </ul> </div> <div class="right"> <ul> <li>one</li> <li>two</li> </ul> </div> <div class="subs"> <div class="right"> <ul> <li>subs one</li> <li>subs two</li> </ul> </div> </div>
Comments
Post a Comment