title: Create Pagination on div using jquery?
body: <p>Hello every one i have here going for the pagination on div using jquery and i am write this code and my pagination is work very well. but here in my static text is 40 line so in the pagination is so long see up to 1 2 3 4 5 etc.. like this. so i want to need the change my pagination code and i want to like this pagination is our code. 1 2 3 4 next last and first time don't show previous then i am click on 2 page no then also show previous 2 3 4 next last. 
  any one know how can do that please help me.</p>
  
  <p>here i am working snippet add in my post.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>//Pagination
   pageSize = 4;
  
   var pageCount =  $(".line-content").length / pageSize;
      
       for(var i = 0 ; i&lt;pageCount;i++){
          
         $("#pagin").append('&lt;li&gt;&lt;a href="#"&gt;'+(i+1)+'&lt;/a&gt;&lt;/li&gt; ');
       }
          $("#pagin li").first().find("a").addClass("current")
      showPage = function(page) {
       $(".line-content").hide();
       $(".line-content").each(function(n) {
           if (n &gt;= pageSize * (page - 1) &amp;&amp; n &lt; pageSize * page)
               $(this).show();
       });        
   }
      
   showPage(1);
  
   $("#pagin li a").click(function() {
       $("#pagin li a").removeClass("current");
       $(this).addClass("current");
       showPage(parseInt($(this).text())) 
   });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.current {
    color: green;
  }
  
  #pagin li {
    display: inline-block;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;div class="line-content"&gt;1 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;2 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;3 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;4 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;5 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;6 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;7 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;8 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;9 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;10 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;11 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;12 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;13 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;14 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;15 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;16 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;17 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;18 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;19 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;20 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;21 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;22 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;23 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;24 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;25 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;26 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;27 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;28 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;29 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;30 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;31 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;32 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;33 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;34 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;35 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;36 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;37 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;38 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;39 I have some content&lt;/div&gt;
  &lt;div class="line-content"&gt;10 I have some content&lt;/div&gt;
  
  &lt;ul class="prev"&gt;prev&lt;/ul&gt;
  &lt;ul id="pagin"&gt;&lt;/ul&gt;
  &lt;ul class="next"&gt;next&lt;/ul&gt;
  &lt;ul class="last"&gt;last&lt;/ul&gt;</code></pre>
  </div>
  </div>
  </p>