title: Hide Pagination using Jquery
body: <p>I have the following HTML</p>
  
  <pre><code>&lt;div class = "pagination"&gt;
    &lt;ul class = "pagination-wrap&gt;
      &lt;li&gt;&lt;a href = "#"&gt;1&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href = "#"&gt;2&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href = "#"&gt;3&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href = "#"&gt;4&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>The list increases if we have more items. My question is how can I remove lists <code>&lt;li&gt;</code> dynamically. For example: if my <code>totalpages = 1</code>, I want to remove everything except 1 and so on.</p>
  
  <pre><code>totalpages = getpages();   //Returns a number from my function
  
  if(totalpages == 1) {
   $("a:contains('2')").hide();
   $("a:contains('3')").hide();
   $("a:contains('4')").hide();
   $("a:contains('5')").hide();
  }
  </code></pre>
  
  <p>Right now I have bunch of if condition like these. Is it possible to do this in one function since I don't want to hard code every scenario. Sort of like: if total pages = 1. exclude 1 and remove everything? </p>
  
  <p>Edit: when totalPages = 3, i want to hide 4 and up but  not 1, 2 and 3.</p>