数据表不工作
Datatable is not working
我正在使用数据表来搜索表内容,但是数据表无法在我的HTML代码
中工作我想在我的表中引入过滤和排序功能。html 脚本中包含的所有表库
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css">
<!-- jQuery -->
<script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js"></script>
<!-- DataTables -->
<script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"></script>
</head>
<body>
<script type="text/javascript">
$('table').dataTable();
</script>
<table style="margin-top:100px">
<thead>
<tr class='header'>
<th>Name</th>
<th>Party</th>
<th>Constituency</th>
<th>Gender</th>
</tr>
</thead>
<tbody><tr>
<th>pom</th>
<th>1</th>
<th>bachni</th>
<th>male</th>
</tr>
<tr>
<th>santosh</th>
<th>2</th>
<th>bachni</th>
<th>male</th>
</tr>
<tr>
<th>deepak</th>
<th>3</th>
<th>bachni</th>
<th>male</th>
</tr>
<tr>
<th>sudhir</th>
<th>1</th>
<th>savarde</th>
<th>male</th>
</tr>
</tbody>
</table>
</body>
</html>
由于你已经把脚本放在DOM之前,你需要把你的jQuery代码放在DOM就绪的处理程序$(document).ready(function() {...});
或更短的$(function(){...}):
此步骤用于确保在执行 jQuery 代码之前所有 DOM 元素都已加载到页面:
$(function() {
$('table').dataTable();
});
试试这段代码现在工作正常:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css">
<!-- jQuery -->
<script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js"></script>
<!-- DataTables -->
<script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"></script>
</head>
<body>
<script type="text/javascript">
$('table').dataTable();
</script>
<table style="margin-top:100px" class="table table-striped table-bordered datatable dataTable">
<thead>
<tr class='header'>
<th>Name</th>
<th>Party</th>
<th>Constituency</th>
<th>Gender</th>
</tr>
</thead>
<tbody><tr>
<th>pom</th>
<th>1</th>
<th>bachni</th>
<th>male</th>
</tr>
<tr>
<th>santosh</th>
<th>2</th>
<th>bachni</th>
<th>male</th>
</tr>
<tr>
<th>deepak</th>
<th>3</th>
<th>bachni</th>
<th>male</th>
</tr>
<tr>
<th>sudhir</th>
<th>1</th>
<th>savarde</th>
<th>male</th>
</tr>
</tbody>
</table>
<script>
$(function() {
$('table').dataTable();
});
</script>
</body>
</html>
请检查此小提琴
相关文章:
- 数据表 + 列搜索 + 整体搜索协同工作 + 服务器端处理
- 数据表自动生成的序列号无法正常工作.对于每一页
- 数据表中的FixedHead没有'删除分页后无法工作
- JQuery 数据表列数据更新工作太慢
- 数据表正则表达式搜索无法按预期工作以实现完全匹配
- aa数据表中的排序无法正常工作
- 无法让数据表与 Django 生成的表一起工作
- 引导工具提示不't在与第一个数据表不同的页面中工作
- 使用jQuery来突出显示不工作的数据表行
- JQuery .on('click')不工作在数据表第二页或行过去11
- 数据表中所有页面总量不工作,只工作当前页面
- 数据表过滤&行高亮不能一起工作
- ajax.dataSrc的数据表不工作
- 在ajax后绘制的数据表上单击事件,该数据表不能从第二页工作
- 具有数据表搜索功能的Daterangepicker无法工作
- 从数据表行打印工作表而不首先打开它
- 数据表插件css不工作
- Javascript在数据表过滤或分页之后不工作
- Vue js和数据表导航不工作
- 哪些文件需要的数据表工作的html页面>