Fiddle: <http://jsfiddle.net/dpD56/4>

I am adding a Next Previous button in a list to split the list into parts. 

Here is the HTML: 

```
<ul id="test">
    <li>1</li>
    <li>2</li>
    <li>3</li>
    <li>4</li>
    <li>5</li>
    <li>6</li>
    <li>7</li>
    <li>8</li>
    <li>9</li>
    <li>10</li>
    <li>11</li>
    <li>12</li>
    <li>13</li>
    <li>14</li>
    <li>15</li>
    <li>16</li>
    <li>17</li>
    <li>18</li>
    <li>19</li>
    <li>20</li>
    <li>21</li>
    <li>22</li>
    <li>23</li>
    <li>24</li>
    <li>25</li>
    <li>26</li>
    <li>27</li>
</ul>

<button id="prev" type='button'>prev</button>
<button id="more" type='button'>next</button>

```

And I am using the following js code to make working Next Previous buttons. 

Here is JS:

```
var pageNumber = 1;
$(document).ready(function () {
    showPage(pageNumber);

    $('#prev').click(function () {
       pageNumber--;
       showPage(pageNumber);
    });

    $('#more').click(function () {
       pageNumber++;
       showPage(pageNumber);
    });

    $('#goto').click(function () {
       pageNumber = +$("#page").val();

       if (!pageNumber) {
            pageNumber = 1;   
       }

       showPage(pageNumber);
    });
});

function showPage(page) {
    var start = (5 * page) - 5;
    var showListItems = $("#test li").splice(start, 5);

    console.log(start, showListItems);

    $("#test li").hide();
    $(showListItems).show();
}

```

This code is working fine for Next & Previous buttons, but Next and Previous buttons are not stopping when there is no more items at end. 

Next button should be disabled or should not working when there is no more item after last item and Previous button should also stop working when there is no previous item or it should be disabled when there is no more items.

But these buttons are performing their functions even if there is no more items and they are showing blank page with the NEXT PREVIOUS BUTTON.