views:

23

answers:

1

I'm very new to jQuery and having some issues figuring out stuff here :)

I want to create a gallery that's something like this.

    [IMAGE]

[previous / next]

[ 1 of 5 ] <- (for example, if I have 5 images, I want to display the numbers)

I figured out up to prev / next button part by using jQuery Cycle Plugin, but i couldn't figure out how to display the [1 of 5] part.

Can someone please lend me a hand ? :)

A: 

Well, I made this simple example on how you can achieve it, using only jQuery without plugins.

The rotation is a simple line. If you are hitting prev and it is already in the first image, go to the last. If you are hitting next and it is already on the last, go to the first.

if ($this.index() == 0) /* Previous */
{
    /* go 1 back or start at the end */
    current = ((current - 1) < 0 ? (total - 1) : (current - 1));
}
else /* Next */
{
    /* go 1 forward or start at the beginning */
    current = ((current + 1) == total ? 0 : (current + 1));
}

Used functions (ref)

BrunoLM
Hi there ! thank you so much for your generous help ! One thing I'm kind of struggling right now is, I can't seem to activate Prev and Next button... I followed your example, but Prev Next button links are not working...do i need to input extra codes in order to make these button working? or modify <a id="Next" href="javascript:;">» next</a> ? (the href part?) sorry for my ignorance !! ^^; but can you please help me out here once again !? I really appreciate your help ^.^ !
Shawn S
oh ! never mind ! i finnally figured it out ! ^_^ Thank you very much ! you really saved my life here !
Shawn S