Apply jQuery code to divs individually -
i'm using following code:
$('.game-list-right-bottom > .game-list-file').each(function(i) { if( % 4 == 0 ) { $(this).nextall().andself().slice(0,4).wrapall('<div class="game-list-files"></div>'); } });
to turn this:
<div class="game-list-right-bottom"> <div class="game-list-file"></div> <div class="game-list-file"></div> <div class="game-list-file"></div> <div class="game-list-file"></div> <div class="game-list-file"></div> <div class="game-list-file"></div> </div>
into this:
<div class="game-list-right-bottom"> <div class="game-list-files"> <div class="game-list-file"></div> <div class="game-list-file"></div> <div class="game-list-file"></div> <div class="game-list-file"></div> </div> <div class="game-list-files"> <div class="game-list-file"></div> <div class="game-list-file"></div> </div> </div>
(basically wrap .game-list-files
every 4 .game-list-file).
the problem have more 1 .game-list-right-bottom
:
<div class="game-list-right-bottom"> <div class="game-list-file"></div> <div class="game-list-file"></div> <div class="game-list-file"></div> </div> <div class="game-list-right-bottom"> <div class="game-list-file"></div> <div class="game-list-file"></div> <div class="game-list-file"></div> <div class="game-list-file"></div> <div class="game-list-file"></div> <div class="game-list-file"></div> </div>
so ends this:
<div class="game-list-right-bottom"> <div class="game-list-file"></div> <div class="game-list-file"></div> <div class="game-list-file"></div> </div> <div class="game-list-right-bottom"> <div class="game-list-file"></div> <div class="game-list-files"> <div class="game-list-file"></div> </div> <div class="game-list-file"></div> <div class="game-list-file"></div> <div class="game-list-file"></div> <div class="game-list-file"></div> </div>
i apply jquery code individually each .game-list-right-bottom
. how archive that?
try this
$('.game-list-right-bottom').each(function () { $(this).children('.game-list-file').each(function(i) { if( % 4 == 0 ) { $(this).nextall().andself().slice(0,4).wrapall('<div class="game-list-files"></div>'); } }); });
Comments
Post a Comment