I have made a simple table to show dataTable something like this in DataTable . The problem is I have tried to do in a similar way like it does.
First of all, I have put the coding below:
<table id="myTable" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Salary</th>
</tr>
</thead>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>$320,800</td>
</tr>
<tr>
<td>Cedric Kelly</td>
<td>Senior Javascript Developer</td>
<td>Edinburgh</td>
<td>22</td>
<td>$433,060</td>
</tr>
<tr>
<td>Sonya Frost</td>
<td>Software Engineer</td>
<td>Edinburgh</td>
<td>23</td>
<td>$103,600</td>
</tr>
</tbody>
</table>
I don't forget to call function something like this:
<script type="text/javascript">
$(document).ready(function(){
$('#myTable').DataTable();
});
</script>
And also I have call external sources as suggested like this:
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="//cdn.datatables.net/1.10.4/js/jquery.data"></script>
The problem is it doesnt work as shown as here. Here is JSFIDDLE . Any idea? Thanks.
Check this link Demo here you must include the js correctly
<link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.0/css/jquery.dataTables.css">
<link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.0/css/jquery.dataTables_themeroller.css">
<script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.1.min.js"></script>
<script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.0/jquery.dataTables.min.js"></script>
I spent hours working this out, turns out I was missing tags needed for the Search to work:
<thead></thead>
and the
<tbody></tbody>
Remove // from the beginning of links. And include https:// before these links. i also faced this issue. But now its working.
To make the table working what you can do is,
$(window).load(()=>{
setTimeout(() => {
$('table').DataTable();
}, 1100);
})
Add $.noConflict();
to your script:
<script type="text/javascript">
$.noConflict();
$(document).ready(function(){
$('#myTable').DataTable();
});
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.