반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- 성신여대편백집
- springboot
- 파이썬
- 퇴사후공무원
- 한남동맛집
- 서울숲누룽지통닭구이
- 통영
- JavaScript
- 자바스크립트에러처리
- tomcat7
- 성신여대맛집
- 한성대맛집
- 방이편백육분삼십
- react
- 통영예쁜카페
- 뚝섬역맛집
- 통영에어비앤비
- 꼴뚜기회
- ELK
- ubuntu자바설치
- gradle
- npm
- 방이편백육분삼십성신여대
- 영화추천
- 돈암동맛집
- 스페인여행
- 성북구맛집
- 통영여행
- 국가직
- 공무원
Archives
- Today
- Total
코린이의 기록
[HTML/JS/CSS] HTML + CSS + JS를 이용한 동적 테이블 페이징 구현 본문
반응형
HTML + CSS + JS를 이용한 동적 테이블 페이징 구현
HTML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | <div class="table-responsive"> <table class="table table-bordered table-hover"> <thead> <tr> <th>Page</th> <th>Visits</th> <th>% New Visits</th> <th>Revenue</th> </tr> </thead> <tbody> <tr> <td>/index.html</td> <td>1265</td> <td>32.3%</td> <td>$321.33</td> </tr> <tr> <td>/about.html</td> <td>261</td> <td>33.3%</td> <td>$234.12</td> </tr> <tr> <td>/sales.html</td> <td>665</td> <td>21.3%</td> <td>$16.34</td> </tr> <tr> <td>/blog.html</td> <td>9516</td> <td>89.3%</td> <td>$1644.43</td> </tr> <tr> <td>/404.html</td> <td>23</td> <td>34.3%</td> <td>$23.52</td> </tr> <tr> <td>/services.html</td> <td>421</td> <td>60.3%</td> <td>$724.32</td> </tr> <tr> <td>/blog/post.html</td> <td>1233</td> <td>93.2%</td> <td>$126.34</td> </tr> <tr> <td>/index.html</td> <td>1265</td> <td>32.3%</td> <td>$321.33</td> </tr> <tr> <td>/about.html</td> <td>261</td> <td>33.3%</td> <td>$234.12</td> </tr> <tr> <td>/sales.html</td> <td>665</td> <td>21.3%</td> <td>$16.34</td> </tr> <tr> <td>/blog.html</td> <td>9516</td> <td>89.3%</td> <td>$1644.43</td> </tr> <tr> <td>/404.html</td> <td>23</td> <td>34.3%</td> <td>$23.52</td> </tr> <tr> <td>/services.html</td> <td>421</td> <td>60.3%</td> <td>$724.32</td> </tr> <tr> <td>/blog/post.html</td> <td>1233</td> <td>93.2%</td> <td>$126.34</td> </tr> <tr> <td>/index.html</td> <td>1265</td> <td>32.3%</td> <td>$321.33</td> </tr> <tr> <td>/about.html</td> <td>261</td> <td>33.3%</td> <td>$234.12</td> </tr> <tr> <td>/sales.html</td> <td>665</td> <td>21.3%</td> <td>$16.34</td> </tr> <tr> <td>/blog.html</td> <td>9516</td> <td>89.3%</td> <td>$1644.43</td> </tr> <tr> <td>/404.html</td> <td>23</td> <td>34.3%</td> <td>$23.52</td> </tr> <tr> <td>/services.html</td> <td>421</td> <td>60.3%</td> <td>$724.32</td> </tr> <tr> <td>/blog/post.html</td> <td>1233</td> <td>93.2%</td> <td>$126.34</td> </tr> <tr> <td>/index.html</td> <td>1265</td> <td>32.3%</td> <td>$321.33</td> </tr> <tr> <td>/about.html</td> <td>261</td> <td>33.3%</td> <td>$234.12</td> </tr> <tr> <td>/sales.html</td> <td>665</td> <td>21.3%</td> <td>$16.34</td> </tr> <tr> <td>/blog.html</td> <td>9516</td> <td>89.3%</td> <td>$1644.43</td> </tr> <tr> <td>/404.html</td> <td>23</td> <td>34.3%</td> <td>$23.52</td> </tr> <tr> <td>/services.html</td> <td>421</td> <td>60.3%</td> <td>$724.32</td> </tr> <tr> <td>/blog/post.html</td> <td>1233</td> <td>93.2%</td> <td>$126.34</td> </tr> </tbody> </table> <ul class="pagination"> </ul> </div> | cs |
CSS
1 2 3 4 5 6 | #pagination a { display:inline-block; margin-right:5px; cursor:pointer; } | cs |
JS
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | function pagination(){ var req_num_row=5; var $tr=jQuery('tbody tr'); var total_num_row=$tr.length; var num_pages=0; if(total_num_row % req_num_row ==0){ num_pages=total_num_row / req_num_row; } if(total_num_row % req_num_row >=1){ num_pages=total_num_row / req_num_row; num_pages++; num_pages=Math.floor(num_pages++); } jQuery('.pagination').append("<li><a class=\"prev\">Previous</a></li>"); for(var i=1; i<=num_pages; i++){ jQuery('.pagination').append("<li><a>"+i+"</a></li>"); jQuery('.pagination li:nth-child(2)').addClass("active"); jQuery('.pagination a').addClass("pagination-link"); } jQuery('.pagination').append("<li><a class=\"next\">Next</a></li>"); $tr.each(function(i){ jQuery(this).hide(); if(i+1 <= req_num_row){ $tr.eq(i).show(); } }); jQuery('.pagination a').click('.pagination-link', function(e){ e.preventDefault(); $tr.hide(); var page=jQuery(this).text(); var temp=page-1; var start=temp*req_num_row; var current_link = temp; jQuery('.pagination li').removeClass("active"); jQuery(this).parent().addClass("active"); for(var i=0; i< req_num_row; i++){ $tr.eq(start+i).show(); } if(temp >= 1){ jQuery('.pagination li:first-child').removeClass("disabled"); } else { jQuery('.pagination li:first-child').addClass("disabled"); } }); jQuery('.prev').click(function(e){ e.preventDefault(); jQuery('.pagination li:first-child').removeClass("active"); }); jQuery('.next').click(function(e){ e.preventDefault(); jQuery('.pagination li:last-child').removeClass("active"); }); } jQuery('document').ready(function(){ pagination(); jQuery('.pagination li:first-child').addClass("disabled"); }); | cs |
반응형
'javascript,HTML,CSS' 카테고리의 다른 글
[javascript] getOutputStream() has already been called for this response (0) | 2019.02.22 |
---|---|
[Jquery] multiselect.js를 이용한 Multi Select Box 구현하기 (0) | 2019.02.20 |
[javascript] <form> tag to Javascript Object & JSON (0) | 2018.12.06 |
[javascript] ajax list object 가져오기 (0) | 2018.10.17 |
[HTML] <form:select> 과 itemValue & itemLabel (0) | 2018.10.08 |
Comments