jquery - Ul list expand - less and more -
assume have 1 this;
<ul> <li>2</li> <li>3</li> <li>4</li> <li>5</li> </ul> i want use jquery show 3 li , after 3 1 append more li named more , when click show li , append in last li named less
this should work.. =) change index number of items want show.
<ul> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> </ul> <script> var index = 2; $('ul li:gt('+index+')').hide(); $('ul').append('<li class="more">more...</li>'); $('ul li.more').click(function() { $('ul li.more').remove(); $('ul li:gt('+index+')').show(); }); </script>
Comments
Post a Comment