On 4/22/09 10:18 AM, "ldexterldesign" <m...@ldexterldesign.co.uk> wrote:

> 
> Hey guys,
> 
> I have 10 separate posts displayed on a page. I want to hide 7 (of the
> oldest) of them and display a link; 'show more posts' - kinda a
> pagination thing I guess.
> 
> My PHP pumps out 10 posts, and I'd like to do the hide/show with JS.
> 
> I'm aware I could simply add and remove a height class, hiding/
> revealing the posts, but I'd like to make it a bit more complex and
> have accurate control over how many posts are shown if my client turns
> around and says he wants 5 posts displayed prior to the button being
> clicked.
> 
> Just thinking about how I might go about this in code I'm thinking of
> doing it the following way. I'm not an excellent programmer, so the
> time you'd, potentially, save me getting it clear in pseudo will most
> likely save me a lot of time this evening. Hell, there might even be a
> plug-in or simpler solution than below you can think of:
> 
> - I get a unique 'post-x' ID for each of the posts, where 'x' is the
> post ID, so I was thinking about just hiding the lowest 7 numeric post
> IDs displayed on the page?
> 
> Thoughts?

say your posts all had class="foopost", could you do something like:

$('.foopost').each(function() {
    if ( $(this).attr('id').match(/(\d+)$/)[1] > x ) {
    ...
    }
});


Reply via email to