Javascript 数据表不工作
我正在使用datatable搜索表内容。但是datatable在我的html代码中无法工作Javascript 数据表不工作,javascript,jquery,Javascript,Jquery,我正在使用datatable搜索表内容。但是datatable在我的html代码中无法工作 我想在我的表中引入过滤和排序功能。html脚本中包含的所有表库 <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>
我想在我的表中引入过滤和排序功能。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>
无标题文件
$('table').dataTable();
名称
聚会
选区
性别
聚甲醛
1.
巴赫尼
男性的
桑托什
2.
巴赫尼
男性的
迪帕克
3.
巴赫尼
男性的
苏希尔
1.
萨瓦德
男性的
因为您已经将脚本放在DOM之前,所以需要将jQuery代码放在处理程序$(document.ready(function(){…})中代码>或更短的形式$(函数(){…}):
此步骤用于确保在执行jQuery代码之前已将所有DOM元素加载到页面:
$(function() {
$('table').dataTable();
});
由于已将脚本放在DOM之前,因此需要将jQuery代码放在处理程序中$(document).ready(function(){…})代码>或更短的形式$(函数(){…}):
此步骤用于确保在执行jQuery代码之前已将所有DOM元素加载到页面:
$(function() {
$('table').dataTable();
});
由于已将脚本放在DOM之前,因此需要将jQuery代码放在处理程序中$(document).ready(function(){…})代码>或更短的形式$(函数(){…}):
此步骤用于确保在执行jQuery代码之前已将所有DOM元素加载到页面:
$(function() {
$('table').dataTable();
});
由于已将脚本放在DOM之前,因此需要将jQuery代码放在处理程序中$(document).ready(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>
无标题文件
$('table').dataTable();
名称
聚会
选区
性别
聚甲醛
1.
巴赫尼
男性的
桑托什
2.
巴赫尼
男性的
迪帕克
3.
巴赫尼
男性的
苏希尔
1.
萨瓦德
男性的
$(函数(){
$('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>
无标题文件
$('table').dataTable();
名称
聚会
选区
性别
聚甲醛
1.
巴赫尼
男性的
桑托什
2.
巴赫尼
男性的
迪帕克
3.
巴赫尼
男性的
苏希尔
1.
萨瓦德
男性的
$(函数(){
$('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>
无标题文件
$('table').dataTable();
名称
聚会
选区
性别
聚甲醛
1.
巴赫尼
男性的
桑托什
2.
巴赫尼
男性的
迪帕克
3.
巴赫尼
男性的
苏希尔
1.
萨瓦德
男性的
$(函数(){
$('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>
无标题文件
$('table').dataTable();
名称
聚会
选区
性别
聚甲醛
1.
巴赫尼
男性的
桑托什
2.
巴赫尼
男性的
迪帕克
3.
巴赫尼
男性的
苏希尔
1.
萨瓦德
男性的
$(函数(){
$('table').dataTable();
});
如果添加DOMReady事件会怎么样?Thanx。。。。。。。。。。。。。。伟大的是行不通的——简洁、准确而且毫无用处。解释正在发生的事情和应该发生的事情。如果添加DOMReady事件会怎么样?Thanx。。。。。。。。。。。。。。伟大的是行不通的——简洁、准确而且毫无用处。解释正在发生的事情和应该发生的事情。如果添加DOMReady事件会怎么样?Thanx。。。。。。。。。。。。。。伟大的是行不通的——简洁、准确而且毫无用处。解释正在发生的事情和应该发生的事情。如果添加DOMReady事件会怎么样?Thanx。。。。。。。。。。。。。。伟大的是行不通的——简洁、准确而且毫无用处。解释正在发生的事情和应该发生的事情。