Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var currPage = 1;
- $("#prev").click(function() {
- if (currPage === 1) return;
- $(`.p${currPage--}`).hide();
- $(`.p${currPage}`).show();
- });
- $("#next").click(function() {
- if (currPage === 3) return;
- $(`.p${currPage++}`).hide();
- $(`.p${currPage}`).show();
- });
- .p2,.p3
- {
- display:none;
- }
- .p1
- {
- display:block;
- }
- <div class="block">
- <ul>
- <li class="element p1">Я элемент 1 (страница1)</li>
- <li class="element p1">Я элемент 2 (страница1)</li>
- <li class="element p1">Я элемент 3 (страница1)</li>
- <!- переход на след. страницу ->
- <li class="element p2">Я элемент 4 (страница2)</li>
- <li class="element p2">Я элемент 5 (страница2)</li>
- <li class="element p2">Я элемент 6 (страница2)</li>
- <li class="element p2">Я элемент 7 (страница2)</li>
- <li class="element p2">Я элемент 8 (страница2)</li>
- <li class="element p2">Я элемент 9 (страница2)</li>
- <!- переход на след. страницу ->
- <li class="element p3">Я элемент 10 (страница3)</li>
- <li class="element p3">Я элемент 11 (страница3)</li>
- </ul>
- </div>
- <div class="buttons">
- <button id="prev">Предыдущая страница</button>
- <button id="next">Следующая страница</button>
- </div>
Add Comment
Please, Sign In to add comment