SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    May 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cool Show more list items ( how can I do it in increments of 9 )?

    Hello!

    I'm working on a page where clicking on more items should work similar to how Google Images works. I need it to only show 9 items at a time, and when you click on "more results" it will show another 9 items at a time. If there are less than 9 items left, it would just show the remaining...

    I have this jquery right now, which does initially show only 9 items, but after you click show more, it loads all of the remaining items. How would I get it to show them in increments of 9 instead?

    Code:
    $('ul')
      .find('li:gt(8)')
      .hide()
      .end()
      .append(
        $('<li>Show More...</li>').click( function(){
          $(this).siblings(':hidden').show().end().remove();
        })
    );

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,712
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by Rzimgd View Post
    I have this jquery right now, which does initially show only 9 items, but after you click show more, it loads all of the remaining items. How would I get it to show them in increments of 9 instead?
    There can be quite a few details to take care of, so the easiest way can be to use a plugin that's designed for the job instead, such as this pagination plugin.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •