gpt4 book ai didi

jquery - 如何启用Bootstrap表格分页和搜索?

转载 作者:行者123 更新时间:2023-12-03 22:59:27 24 4
gpt4 key购买 nike

我一直在关注two有关向 Bootstrap 表添加分页的指南,但是当我添加所需的链接和脚本时,分页或搜索不会在 Bootstrap 表上呈现。

我尝试按照此解决方案的建议将 jQuery 引用放置在 head 标记的开头,但没有什么区别。

我确信这只是外部库 cdn 引用的顺序不匹配,但我不确定顺序是否正确。

我还检查了脚本是否引用了正确的表,它确实做到了 - “升级”

问题:

如何组织 jquerybootstrap 引用来显示表格分页?

标记:( View 标记的要点)

<!DOCTYPE html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.min.js"></script>
<script type="text/javascript" language="javascript" src="media/js/jquery.dataTables.js"></script>

<link rel="stylesheet" type="text/css" href="media/css/jquery.dataTables.css">

<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container body-content">
<div class="page-header">
<label class="heading">History</label>
<div class="form-group">
<fieldset>
<form action="" class="form-group" method="post">
<div class="table-responsive">
<div class="table-responsive">

<table id="escalation" class="table table-striped table-bordered" cellspacing="0" width="100%">
<thead>
<tr>
<th>Application</th>
<th>EMOPOP</th>
<th>Stats</th>
<th>Statement</th>
<th>Time</th>
<th>Updated</th>
<th>Details</th>
<th>Price</th>
</tr>
</thead>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$320,800</td>
<td>2011/04/25</td>
<td>$320,800</td>
</tr>
</tbody>
</table>
</div>
</div>
</form> <!--END OF FORM ^^-->
</fieldset>
</div>
<hr />
</div>
</div>
</body>
<script>
$(document).ready(function () {
$('#escalation').dataTable();
});
</script>

最佳答案

这段代码运行得很好,只需使用下面的片段进行测试

<!DOCTYPE html>   
<html lang="en">
<head>
<meta charset="utf-8">
<title>Final Output</title>
<meta name="description" content="Bootstrap.">
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<link rel="stylesheet" href="http://cdn.datatables.net/1.10.2/css/jquery.dataTables.min.css"></style>
<script type="text/javascript" src="http://cdn.datatables.net/1.10.2/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
</head>
<body style="margin:20px auto">
<div class="container">
<div class="row header" style="text-align:center;color:green">
<h3>Bootstrap</h3>
</div>
<table id="myTable" class="table table-striped" >
<thead>
<tr>
<th>ENO</th>
<th>EMPName</th>
<th>Country</th>
<th>Salary</th>
</tr>
</thead>
<tbody>
<tr>
<td>001</td>
<td>Anusha</td>
<td>India</td>
<td>10000</td>
</tr>
<tr>
<td>002</td>
<td>Charles</td>
<td>United Kingdom</td>
<td>28000</td>
</tr>
<tr>
<td>003</td>
<td>Sravani</td>
<td>Australia</td>
<td>7000</td>
</tr>
<tr>
<td>004</td>
<td>Amar</td>
<td>India</td>
<td>18000</td>
</tr>
<tr>
<td>005</td>
<td>Lakshmi</td>
<td>India</td>
<td>12000</td>
</tr>
<tr>
<td>006</td>
<td>James</td>
<td>Canada</td>
<td>50000</td>
</tr>

<tr>
<td>007</td>
<td>Ronald</td>
<td>US</td>
<td>75000</td>
</tr>
<tr>
<td>008</td>
<td>Mike</td>
<td>Belgium</td>
<td>100000</td>
</tr>
<tr>
<td>009</td>
<td>Andrew</td>
<td>Argentina</td>
<td>45000</td>
</tr>

<tr>
<td>010</td>
<td>Stephen</td>
<td>Austria</td>
<td>30000</td>
</tr>
<tr>
<td>011</td>
<td>Sara</td>
<td>China</td>
<td>750000</td>
</tr>
<tr>
<td>012</td>
<td>JonRoot</td>
<td>Argentina</td>
<td>65000</td>
</tr>
</tbody>
</table>
</div>
</body>
<script>
$(document).ready(function(){
$('#myTable').dataTable();
});
</script>
</html>

关于jquery - 如何启用Bootstrap表格分页和搜索?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37259682/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com