gpt4 book ai didi

javascript - 数据表将输入搜索集中在 Bootstrap Modal 上

转载 作者:行者123 更新时间:2023-11-28 03:30:37 25 4
gpt4 key购买 nike

我在 bootstrap3 模式上使用数据表,我想专注于搜索输入过滤器。当我单击按钮时,打开带有数据表的模式。

我已经尝试过工作,但没有在模态上使用数据表。

Auto focus on search box of jQuery DataTable

datatable search field always focus stop all other action

最佳答案

这是示例代码,

<!doctype html>
<html>
<head>
<title>Employees</title>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>

<script>
$(document).ready(function() {
$('#lookup').DataTable(
{
"responsive": true
});
$('#lookup_filter input').focus()
//$('#lookup_filter [type="search"]').focus()
});
</script>

<button class="btn-warning fa fa-search" data-toggle="modal" data-target="#Emply">Employee</button>

<div class="modal fade" id="Emply" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="bg-warning modal-title" style="text-align:center" id="myModalLabel">List Employee</h4>
</div></strong>
<div class="modal-body">
<table id="lookup" class="display responsive" width="100%">
<thead>
<tr>
<th>No</th>
<th>ID</th>
<th>Employee</th>
<th>Saldo</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>40001</td>
<td>JOHN THOR</td>
<td>10000</td>
</tr>
<tr>
<td>2</td>
<td>40002</td>
<td>JOHN WICK</td>
<td>20000</td>
</tr>
<tr>
<td>2</td>
<td>40003</td>
<td>JOHN CENA</td>
<td>20000</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>

关于javascript - 数据表将输入搜索集中在 Bootstrap Modal 上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58211352/

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