jQuery DataTable is easy to search, Paging, sorting on HTML table.

Now am going to create a HTML Page with some data using HTML Table.

HTML Code:

  1. <html>
  2. <head>
  3. <title>Using Jquery Datatabble</title>
  4. <head>
  5. <body>
  6. <table id="datatable">
  7. <thead>
  8. <tr>
  9. <th> Username </th>
  10. <th> Password </th>
  11. <th> Created by </th>
  12. </tr>
  13. </thead>
  14. <tbody>
  15. <tr>
  16. <td> Vinodh </td>
  17. <td> jquery@123 </td>
  18. <td> Admin </td>
  19. </tr>
  20. <tr>
  21. <td> Santhakumar </td>
  22. <td> jquery@123 </td>
  23. <td> Guest </td>
  24. </tr>
  25. </tbody>
  26. </table>
  27. </body>
  28. </html>
Run in browser

Output look like this:

Output

Now am going to add a Jquery references for datatable:

Download all this references and include it into your html page.

Add this simple script to call the jquery datatable.

  1. <script type="text/javascript">
  2. $(document).ready(function () {
  3. $('#datatable').dataTable({ /Get the ID of the table
  4. });
  5. });
  6. </script>
Full Code:
  1. <html>
  2. <head>
  3. <title>Using Jquery Datatable</title>
  4. <head>
  5. <script src="https://code.jquery.com/jquery-1.11.3.min.js" type="text/javascript"></script>
  6. <script src="https://cdn.datatables.net/1.10.9/js/jquery.dataTables.min.js" type="text/javascript"></script>
  7. <link rel="stylesheet" href="https://cdn.datatables.net/1.10.9/css/jquery.dataTables.min.css" />
  8. <script type="text/javascript">
  9. $(document).ready(function ()
  10. {
  11. $('#datatable').dataTable(
  12. {});
  13. });
  14. </script>
  15. </script>
  16. </head>
  17. <body>
  18. <table id="datatable">
  19. <thead>
  20. <tr>
  21. <th> Username </th>
  22. <th> Password </th>
  23. <th> Created by </th>
  24. </tr>
  25. </thead>
  26. <tbody>
  27. <tr>
  28. <td> Vinodh </td>
  29. <td> jquery@123 </td>
  30. <td> Admin </td>
  31. </tr>
  32. <tr>
  33. <td> Santhakumar </td>
  34. <td> jquery@123 </td>
  35. <td> Guest </td>
  36. </tr>
  37. </tbody>
  38. </table>
  39. </body>
  40. </html>
Now finally output look a like this:

finally output

Now am going to search for “Vinodh”.

search