woofMaranon
woofMaranon

Reputation: 144

How to convert my simple table to the Datatables

mytable.php

<table id="tableid">
    <thead>
        <tr>
            <th scope="col">A</th>
            <th scope="col">B</th>  
            <th scope="col">C</th> 
            <th scope="col">D</th>
        </tr>
    </thead>
    <tbody>
      <tr>
    <td>0</td>
    <td>2</td>
    <td>3</td>
    <td>4</td>
</tr>
<tr>
    <td>5</td>
    <td>6</td>
    <td>7</td>
    <td>8</td>
</tr>
<tr>
    <td>9</td>
    <td>10</td>
    <td>11</td>
    <td>12</td>
</tr>
</tbody>
</table>

Hello Guys, Can anyone help me how to convert my code to the Datatables? Sorry Guys for this question I try to convert but it didn't work. I'm a beginner and still learning how to use tables

Upvotes: 0

Views: 332

Answers (1)

Vishal Pawar
Vishal Pawar

Reputation: 376

Script

$(document).ready(function() {
    $('#example').DataTable();
} );

HTML

<table id="example" class="display" style="width:100%">

 <tr>
......
</tr>
</table>

In addition to the above code, the following Javascript library files are loaded for use in this example:

https://code.jquery.com/jquery-3.5.1.js

https://cdn.datatables.net/1.10.21/js/jquery.dataTables.min.js

Upvotes: 1

Related Questions