Brief introduction of preface
DataTables is a JavaScript class library that operates on HTML tables, changes table CSS styles, and enhances the functionality of the table to make it more interactive.
DataTables relies on the jquery class library.
Getting Started example
Environment: DataTables 1.10.11, JQuery 2.2.1
Getting Started code:
<!DOCTYPE HTML><HTML> <Head> <MetaCharSet= "Utf-8" /> <title>DataTable Learning</title> <Linkrel= "stylesheet"type= "Text/css"href= "//cdn.datatables.net/1.10.11/css/jquery.datatables.min.css" /> </Head> <Body> <TableID= "table_id"class= "Display"> <thead> <TR> <th>Column 1</th> <th>Column 2</th> </TR> </thead> <tbody> <TR> <TD>Row 1 Data 1</TD> <TD>Row 1 Data 2</TD> </TR> <TR> <TD>Row 2 Data 1</TD> <TD>Row 2 Data 2</TD> </TR> </tbody> </Table> <!--jquery.js to be introduced before Jquery.dataTables.min.js - <Scriptsrc= "//cdn.bootcss.com/jquery/2.2.1/jquery.js"type= "Text/javascript"></Script> <Scriptsrc= "//cdn.datatables.net/1.10.11/js/jquery.datatables.min.js"type= "Text/javascript"></Script> <Scripttype= "Text/javascript"> $(function() { $('#table_id'). DataTable (); }) </Script> </Body></HTML>
key points of use
1, first introduce dataTables necessary documents: Jquery.dataTables.min.css and Jquery.dataTables.min.js
2. Because the DataTable relies on jquery, before introducing the DataTables JS file, you should also introduce the jquery file first: jquery.js
3, define the ordinary HTML table: <table id= "table_id" >...</table>
4. Initialize table with DataTable: $ (' #table_id '). DataTable ();
5. The example table has a style: class= "display", which is the style in the DataTables CSS file.
DataTables Getting Started with