grouping - Using jQuery to group varying number of divs wtih same class until "last" class -
i've seen other related questions not quite mine.
i have blocks of code varying number of rows , want group rows, including "last" div:
<div class="row"></div> <div class="row"></div> <div class="last"></div> <br> <div class="row"></div> <div class="row"></div> <div class="row"></div> <div class="row"></div> <div class="row"></div> <div class="last"></div> <br> <div class="row"></div> <div class="row"></div> <div class="row"></div> <div class="last"></div>
i want:
<div class="wrapper"> <div class="row"></div> <div class="row"></div> <div class="last"></div> </div> <br> <div class="wrapper"> <div class="row"></div> <div class="row"></div> <div class="row"></div> <div class="row"></div> <div class="row"></div> <div class="last"></div> </div> <br> <div class="wrapper"> <div class="row"></div> <div class="row"></div> <div class="row"></div> <div class="last"></div> </div>
i've tried various find, addbefore, wrapall variations can't it.
i've tried variations of:
$(this).find(".row, .last").wrapall('<div class="wrapper"></div>');
we can acheive combining prevall , wrapall. below ocde
$("div.last").each(function() { $(this).prevall(".row").addback().wrapall("<div class='wrapper' />"); });
Comments
Post a Comment