我一直在尝试这样做,但是当我输入一些内容进行过滤时,我没有得到任何结果。我认为都是正确的,但我不知道。任何帮助表示赞赏
这是我的代码:
<div id="resultado">
<div class="filtros" style="display: flex; justify-content: space-around;">
<div>
<input autocomplete='off' class='filter' name='name' placeholder='Proyecto' data-col='Proyecto'/>
<input autocomplete='off' class='filter' name='name' placeholder='Trabajador' data-col='Trabajador'/>
<input autocomplete='off' class='filter' name='name' placeholder='Año' data-col='Año'/>
<input autocomplete='off' class='filter' name='name' placeholder='Mes' data-col='Mes'/>
</div>
</div>
<table class="table" id="myTable">
<thead class="thead-dark">
<tr>
<th scope="col">Proyecto</th>
<th scope="col">Trabajador</th>
<th scope="col">Año</th>
<th scope="col">Mes</th>
<th scope="col">Horas totales</th>
</tr>
</thead>
<tbody>
<?php
while($row = $result->fetch_assoc()) {
echo "<tr><td>".$row['proyecto']."</td><td>".$row['trabajador']."</td><td>".$row['año']."</td><td>".$row['mes']."</td><td>".$row['Hours']."</td></tr>";
}
?>
</tbody>
</table>
<script>
$(document).ready(function() {
$('.filter').multifilter()
})
</script>
编辑:我导入了多过滤器,但这不在代码中
这个插件需要一个旧的 jQuery 版本。
$('.filter').multifilter()
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<link rel="stylesheet"
href="https://www.jqueryscript.net/demo/jQuery-Plugin-To-Filter-Html-Table-with-Multiple-Criteria-multifilter/style.css">
<script src="https://www.jqueryscript.net/demo/jQuery-Plugin-To-Filter-Html-Table-with-Multiple-Criteria-multifilter/multifilter.js"></script>
<div id="resultado">
<div class="filtros" style="display: flex; justify-content: space-around;">
<div>
<input autocomplete='off' class='filter' name='Proyecto' placeholder='Proyecto' data-col='Proyecto'/>
<input autocomplete='off' class='filter' name='Trabajador' placeholder='Trabajador' data-col='Trabajador'/>
<input autocomplete='off' class='filter' name='Año' placeholder='Año' data-col='Año'/>
<input autocomplete='off' class='filter' name='Mes' placeholder='Mes' data-col='Mes'/>
</div>
</div>
<table class="table" id="myTable">
<thead class="thead-dark">
<tr>
<th scope="col">Proyecto</th>
<th scope="col">Trabajador</th>
<th scope="col">Año</th>
<th scope="col">Mes</th>
<th scope="col">Horas totales</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>2</td>
<td>2</td>
<td>2</td>
<td>2</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>3</td>
<td>3</td>
<td>3</td>
<td>3</td>
</tr>
</tbody>
</table>
</div>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句