javascript - 用自定义搜索框替换默认搜索框
问题描述
我正在使用 jQuery DataTables,并且在输出中显示了两个搜索框,但我只想显示自定义搜索框。
如何隐藏默认的 DataTables 搜索框?
只需要自定义搜索框。
HTML
<div class="tab-inn">
<div class="table-responsive table-desi">
<table class="table table-hover">
<thead>
<tr>
<th>ID</th>
<th>Part Number</th>
<th>Bid</th>
<th>Model</th>
</tr>
</thead>
<tbody>
<?php while ($row = mysql_fetch_array($r_query)){ ?>
<tr>
<td><?php echo $row['id']; ?></td>
<td><?php echo $row['partnumber']; ?></td>
<td><?php echo $row['bid']; ?></td>
<td><?php echo $row['model']; ?></td>
</tr>
<?php } ?>
</table>
</div>
</div>
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" type="text/css" href="http://cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css" />
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/1.5.2/css/buttons.dataTables.min.css" />
JavaScript
<script>
$(document).ready(function (){
var table = $('table').DataTable({
dom: 'Bfrtip',
buttons: ['copy', 'csv', 'excel', 'pdf', 'print','pageLength']
});
$('#mySearch').on('keyup redraw', function() {
var searchString = '(' + $('#mySearch').val().split(' ').join('|') + ')';
table.search(searchString, true).draw(true);
});
});
</script>
解决方案
推荐阅读
- azure-functions - 从 Azure 函数到 Azure 队列的消息双重排队
- c - 装配函数将 strFrom 添加到 StrTo 的末尾
- python - “for”循环中的 Python 异步任务
- python - os.system 在 python 中多次打开同一个应用程序
- sql - 如何动态跳过顶行 SQL
- r - 依靠 data.table 完成所有组合
- intellij-idea - Intellij 结构搜索 - 复杂的方法调用更改
- java - 你如何在颤振中保护一个宁静的 api 端点
- google-cloud-platform - 大查询“SELECT * EXCEPT”
- r - 添加一个节点并使用 igraph 与每个其他节点连接