Counting divs for pagination in Jquery
Posted
by Craig Ward
on Stack Overflow
See other posts from Stack Overflow
or by Craig Ward
Published on 2010-05-17T12:53:17Z
Indexed on
2010/05/17
13:00 UTC
Read the original article
Hit count: 279
I want to create a nice pagination in Jquery for a number of divs I have. EG:
<div class="container">
<div id="one">content</div>
<div id="two">content</div>
<div id="three">content</div>
<div id="four">content</div>
</div>
The number will not always be the same so I need to count the divs, and display a pagination like the one below.
1|2|3|4
Clicking on the page number would display the relevant div. I know how to show and hide elements using Jquery and css and have figured out I can count the divs using var numPages = $('.container').size();
but I can't work out how I can display the pagination.
Any pointers?
© Stack Overflow or respective owner