How I can limit number child of div jquery or javascript? -
how can limit display number (ex: 6) child of div jquery or javascript or other method?
<div class="parent"> <!--start--> <div class="child">text</div> <div class="child">text</div> <div class="child">text</div> <div class="child">text</div> <div class="child">text</div> <div class="child">text</div> <!--end--> <div class="child">text</div> <div class="child">text</div> <div class="child">text</div> <div class="child">text</div> <div class="child">text</div> <div class="child">text</div> </div>
what want .slice
method.
var divs = $(".parent .child").slice(0, 6); console.log(divs.length);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="parent"> <!--start--> <div class="child">text</div> <div class="child">text</div> <div class="child">text</div> <div class="child">text</div> <div class="child">text</div> <div class="child">text</div> <!--end--> <div class="child">text</div> <div class="child">text</div> <div class="child">text</div> <div class="child">text</div> <div class="child">text</div> <div class="child">text</div> </div>
Comments
Post a Comment