JQuery笔记JQuery.DataTable.js使用。
相关文件:
https://git.coding.net/HULANG-BTB/JQuery.DataTable.js.git
HTML代码:
1 <html> 2 <head> 3 <title>DataTable</title> 4 <link rel="stylesheet" href="./jquery.dataTables.min.css"> 5 </head> 6 <body> 7 <table id="example" class="display" style="width:100%"> 8 <thead> 9 <tr> 10 <th>Name</th> 11 <th>Position</th> 12 <th>Office</th> 13 <th>Age</th> 14 <th>Start date</th> 15 <th>Salary</th> 16 </tr> 17 </thead> 18 <tbody> 19 <tr> 20 <td>Tiger Nixon</td> 21 <td>System Architect</td> 22 <td>Edinburgh</td> 23 <td>61</td> 24 <td>2011/04/25</td> 25 <td>$320,800</td> 26 </tr> 27 <tr> 28 <td>Garrett Winters</td> 29 <td>Accountant</td> 30 <td>Tokyo</td> 31 <td>63</td> 32 <td>2011/07/25</td> 33 <td>$170,750</td> 34 </tr> 35 <tr> 36 <td>Ashton Cox</td> 37 <td>Junior Technical Author</td> 38 <td>San Francisco</td> 39 <td>66</td> 40 <td>2009/01/12</td> 41 <td>$86,000</td> 42 </tr> 43 <tr> 44 <td>Cedric Kelly</td> 45 <td>Senior Javascript Developer</td> 46 <td>Edinburgh</td> 47 <td>22</td> 48 <td>2012/03/29</td> 49 <td>$433,060</td> 50 </tr> 51 <tr> 52 <td>Airi Satou</td> 53 <td>Accountant</td> 54 <td>Tokyo</td> 55 <td>33</td> 56 <td>2008/11/28</td> 57 <td>$162,700</td> 58 </tr> 59 <tr> 60 <td>Brielle Williamson</td> 61 <td>Integration Specialist</td> 62 <td>New York</td> 63 <td>61</td> 64 <td>2012/12/02</td> 65 <td>$372,000</td> 66 </tr> 67 <tr> 68 <td>Herrod Chandler</td> 69 <td>Sales Assistant</td> 70 <td>San Francisco</td> 71 <td>59</td> 72 <td>2012/08/06</td> 73 <td>$137,500</td> 74 </tr> 75 <tr> 76 <td>Rhona Davidson</td> 77 <td>Integration Specialist</td> 78 <td>Tokyo</td> 79 <td>55</td> 80 <td>2010/10/14</td> 81 <td>$327,900</td> 82 </tr> 83 <tr> 84 <td>Colleen Hurst</td> 85 <td>Javascript Developer</td> 86 <td>San Francisco</td> 87 <td>39</td> 88 <td>2009/09/15</td> 89 <td>$205,500</td> 90 </tr> 91 <tr> 92 <td>Sonya Frost</td> 93 <td>Software Engineer</td> 94 <td>Edinburgh</td> 95 <td>23</td> 96 <td>2008/12/13</td> 97 <td>$103,600</td> 98 </tr> 99 <tr> 100 <td>Jena Gaines</td> 101 <td>Office Manager</td> 102 <td>London</td> 103 <td>30</td> 104 <td>2008/12/19</td> 105 <td>$90,560</td> 106 </tr> 107 <tr> 108 <td>Quinn Flynn</td> 109 <td>Support Lead</td> 110 <td>Edinburgh</td> 111 <td>22</td> 112 <td>2013/03/03</td> 113 <td>$342,000</td> 114 </tr> 115 <tr> 116 <td>Charde Marshall</td> 117 <td>Regional Director</td> 118 <td>San Francisco</td> 119 <td>36</td> 120 <td>2008/10/16</td> 121 <td>$470,600</td> 122 </tr> 123 <tr> 124 <td>Haley Kennedy</td> 125 <td>Senior Marketing Designer</td> 126 <td>London</td> 127 <td>43</td> 128 <td>2012/12/18</td> 129 <td>$313,500</td> 130 </tr> 131 <tr> 132 <td>Tatyana Fitzpatrick</td> 133 <td>Regional Director</td> 134 <td>London</td> 135 <td>19</td> 136 <td>2010/03/17</td> 137 <td>$385,750</td> 138 </tr> 139 <tr> 140 <td>Michael Silva</td> 141 <td>Marketing Designer</td> 142 <td>London</td> 143 <td>66</td> 144 <td>2012/11/27</td> 145 <td>$198,500</td> 146 </tr> 147 <tr> 148 <td>Paul Byrd</td> 149 <td>Chief Financial Officer (CFO)</td> 150 <td>New York</td> 151 <td>64</td> 152 <td>2010/06/09</td> 153 <td>$725,000</td> 154 </tr> 155 <tr> 156 <td>Gloria Little</td> 157 <td>Systems Administrator</td> 158 <td>New York</td> 159 <td>59</td> 160 <td>2009/04/10</td> 161 <td>$237,500</td> 162 </tr> 163 <tr> 164 <td>Bradley Greer</td> 165 <td>Software Engineer</td> 166 <td>London</td> 167 <td>41</td> 168 <td>2012/10/13</td> 169 <td>$132,000</td> 170 </tr> 171 <tr> 172 <td>Dai Rios</td> 173 <td>Personnel Lead</td> 174 <td>Edinburgh</td> 175 <td>35</td> 176 <td>2012/09/26</td> 177 <td>$217,500</td> 178 </tr> 179 <tr> 180 <td>Jenette Caldwell</td> 181 <td>Development Lead</td> 182 <td>New York</td> 183 <td>30</td> 184 <td>2011/09/03</td> 185 <td>$345,000</td> 186 </tr> 187 <tr> 188 <td>Yuri Berry</td> 189 <td>Chief Marketing Officer (CMO)</td> 190 <td>New York</td> 191 <td>40</td> 192 <td>2009/06/25</td> 193 <td>$675,000</td> 194 </tr> 195 <tr> 196 <td>Caesar Vance</td> 197 <td>Pre-Sales Support</td> 198 <td>New York</td> 199 <td>21</td> 200 <td>2011/12/12</td> 201 <td>$106,450</td> 202 </tr> 203 <tr> 204 <td>Doris Wilder</td> 205 <td>Sales Assistant</td> 206 <td>Sidney</td> 207 <td>23</td> 208 <td>2010/09/20</td> 209 <td>$85,600</td> 210 </tr> 211 <tr> 212 <td>Angelica Ramos</td> 213 <td>Chief Executive Officer (CEO)</td> 214 <td>London</td> 215 <td>47</td> 216 <td>2009/10/09</td> 217 <td>$1,200,000</td> 218 </tr> 219 <tr> 220 <td>Gavin Joyce</td> 221 <td>Developer</td> 222 <td>Edinburgh</td> 223 <td>42</td> 224 <td>2010/12/22</td> 225 <td>$92,575</td> 226 </tr> 227 <tr> 228 <td>Jennifer Chang</td> 229 <td>Regional Director</td> 230 <td>Singapore</td> 231 <td>28</td> 232 <td>2010/11/14</td> 233 <td>$357,650</td> 234 </tr> 235 <tr> 236 <td>Brenden Wagner</td> 237 <td>Software Engineer</td> 238 <td>San Francisco</td> 239 <td>28</td> 240 <td>2011/06/07</td> 241 <td>$206,850</td> 242 </tr> 243 <tr> 244 <td>Fiona Green</td> 245 <td>Chief Operating Officer (COO)</td> 246 <td>San Francisco</td> 247 <td>48</td> 248 <td>2010/03/11</td> 249 <td>$850,000</td> 250 </tr> 251 <tr> 252 <td>Shou Itou</td> 253 <td>Regional Marketing</td> 254 <td>Tokyo</td> 255 <td>20</td> 256 <td>2011/08/14</td> 257 <td>$163,000</td> 258 </tr> 259 <tr> 260 <td>Michelle House</td> 261 <td>Integration Specialist</td> 262 <td>Sidney</td> 263 <td>37</td> 264 <td>2011/06/02</td> 265 <td>$95,400</td> 266 </tr> 267 <tr> 268 <td>Suki Burks</td> 269 <td>Developer</td> 270 <td>London</td> 271 <td>53</td> 272 <td>2009/10/22</td> 273 <td>$114,500</td> 274 </tr> 275 <tr> 276 <td>Prescott Bartlett</td> 277 <td>Technical Author</td> 278 <td>London</td> 279 <td>27</td> 280 <td>2011/05/07</td> 281 <td>$145,000</td> 282 </tr> 283 <tr> 284 <td>Gavin Cortez</td> 285 <td>Team Leader</td> 286 <td>San Francisco</td> 287 <td>22</td> 288 <td>2008/10/26</td> 289 <td>$235,500</td> 290 </tr> 291 <tr> 292 <td>Martena Mccray</td> 293 <td>Post-Sales support</td> 294 <td>Edinburgh</td> 295 <td>46</td> 296 <td>2011/03/09</td> 297 <td>$324,050</td> 298 </tr> 299 <tr> 300 <td>Unity Butler</td> 301 <td>Marketing Designer</td> 302 <td>San Francisco</td> 303 <td>47</td> 304 <td>2009/12/09</td> 305 <td>$85,675</td> 306 </tr> 307 <tr> 308 <td>Howard Hatfield</td> 309 <td>Office Manager</td> 310 <td>San Francisco</td> 311 <td>51</td> 312 <td>2008/12/16</td> 313 <td>$164,500</td> 314 </tr> 315 <tr> 316 <td>Hope Fuentes</td> 317 <td>Secretary</td> 318 <td>San Francisco</td> 319 <td>41</td> 320 <td>2010/02/12</td> 321 <td>$109,850</td> 322 </tr> 323 <tr> 324 <td>Vivian Harrell</td> 325 <td>Financial Controller</td> 326 <td>San Francisco</td> 327 <td>62</td> 328 <td>2009/02/14</td> 329 <td>$452,500</td> 330 </tr> 331 <tr> 332 <td>Timothy Mooney</td> 333 <td>Office Manager</td> 334 <td>London</td> 335 <td>37</td> 336 <td>2008/12/11</td> 337 <td>$136,200</td> 338 </tr> 339 <tr> 340 <td>Jackson Bradshaw</td> 341 <td>Director</td> 342 <td>New York</td> 343 <td>65</td> 344 <td>2008/09/26</td> 345 <td>$645,750</td> 346 </tr> 347 <tr> 348 <td>Olivia Liang</td> 349 <td>Support Engineer</td> 350 <td>Singapore</td> 351 <td>64</td> 352 <td>2011/02/03</td> 353 <td>$234,500</td> 354 </tr> 355 <tr> 356 <td>Bruno Nash</td> 357 <td>Software Engineer</td> 358 <td>London</td> 359 <td>38</td> 360 <td>2011/05/03</td> 361 <td>$163,500</td> 362 </tr> 363 <tr> 364 <td>Sakura Yamamoto</td> 365 <td>Support Engineer</td> 366 <td>Tokyo</td> 367 <td>37</td> 368 <td>2009/08/19</td> 369 <td>$139,575</td> 370 </tr> 371 <tr> 372 <td>Thor Walton</td> 373 <td>Developer</td> 374 <td>New York</td> 375 <td>61</td> 376 <td>2013/08/11</td> 377 <td>$98,540</td> 378 </tr> 379 <tr> 380 <td>Finn Camacho</td> 381 <td>Support Engineer</td> 382 <td>San Francisco</td> 383 <td>47</td> 384 <td>2009/07/07</td> 385 <td>$87,500</td> 386 </tr> 387 <tr> 388 <td>Serge Baldwin</td> 389 <td>Data Coordinator</td> 390 <td>Singapore</td> 391 <td>64</td> 392 <td>2012/04/09</td> 393 <td>$138,575</td> 394 </tr> 395 <tr> 396 <td>Zenaida Frank</td> 397 <td>Software Engineer</td> 398 <td>New York</td> 399 <td>63</td> 400 <td>2010/01/04</td> 401 <td>$125,250</td> 402 </tr> 403 <tr> 404 <td>Zorita Serrano</td> 405 <td>Software Engineer</td> 406 <td>San Francisco</td> 407 <td>56</td> 408 <td>2012/06/01</td> 409 <td>$115,000</td> 410 </tr> 411 <tr> 412 <td>Jennifer Acosta</td> 413 <td>Junior Javascript Developer</td> 414 <td>Edinburgh</td> 415 <td>43</td> 416 <td>2013/02/01</td> 417 <td>$75,650</td> 418 </tr> 419 <tr> 420 <td>Cara Stevens</td> 421 <td>Sales Assistant</td> 422 <td>New York</td> 423 <td>46</td> 424 <td>2011/12/06</td> 425 <td>$145,600</td> 426 </tr> 427 <tr> 428 <td>Hermione Butler</td> 429 <td>Regional Director</td> 430 <td>London</td> 431 <td>47</td> 432 <td>2011/03/21</td> 433 <td>$356,250</td> 434 </tr> 435 <tr> 436 <td>Lael Greer</td> 437 <td>Systems Administrator</td> 438 <td>London</td> 439 <td>21</td> 440 <td>2009/02/27</td> 441 <td>$103,500</td> 442 </tr> 443 <tr> 444 <td>Jonas Alexander</td> 445 <td>Developer</td> 446 <td>San Francisco</td> 447 <td>30</td> 448 <td>2010/07/14</td> 449 <td>$86,500</td> 450 </tr> 451 <tr> 452 <td>Shad Decker</td> 453 <td>Regional Director</td> 454 <td>Edinburgh</td> 455 <td>51</td> 456 <td>2008/11/13</td> 457 <td>$183,000</td> 458 </tr> 459 <tr> 460 <td>Michael Bruce</td> 461 <td>Javascript Developer</td> 462 <td>Singapore</td> 463 <td>29</td> 464 <td>2011/06/27</td> 465 <td>$183,000</td> 466 </tr> 467 <tr> 468 <td>Donna Snider</td> 469 <td>Customer Support</td> 470 <td>New York</td> 471 <td>27</td> 472 <td>2011/01/25</td> 473 <td>$112,000</td> 474 </tr> 475 </tbody> 476 <tfoot> 477 <tr> 478 <th>Name</th> 479 <th>Position</th> 480 <th>Office</th> 481 <th>Age</th> 482 <th>Start date</th> 483 <th>Salary</th> 484 </tr> 485 </tfoot> 486 </table> 487 <script src="./jquery-3.3.1.js"></script> 488 <script src="./jquery.dataTables.min.js"></script> 489 <script> 490 $(document).ready(function() { 491 $('#example').DataTable(); 492 $('#example').removeClass( 'display' ).addClass('table table-striped table-bordered'); 493 } ); 494 495 </script> 496 </body> 497 </html>
效果: