Html-JqueryNo Comments

default thumbnail

Suppose we have 7 li in a ul and we want to show 4 li in front end. Is it possible. Yes, you can hide 3 li using jquery. Below is the code.

HTML

<ul class="myUl">
     <li>One</li>
     <li>Two</li>
     <li>Three</li>
     <li>Four</li>
     <li>Five</li>
     <li>Six</li>
     <li>Seven</li>
</ul>

Jquery

$('ul.more_stories li').hide().slice(0, 3).show(); 

If we have to show 4 li of a ul then slide(0,3) because it starts from 0,1,2,3. Thus, these are

Be the first to post a comment.

Add a comment