javascript - 使用输入框和选择框过滤 html 表
问题描述
是否可以修改当前基于多个输入过滤 html 表的现有代码,以便它也过滤所有选择框?
我最初尝试将 querySelectorAll('input') 更改为 document.querySelectorAll('input, select'),但这破坏了代码的其他部分。
const query = q => document.querySelectorAll(q);
const filters = Array.from(document.querySelectorAll('input')).map(e => new RegExp(e.value, 'i'));
query('tbody tr').forEach(row => row.style.display =
filters.every((f, i) => f.test(row.cells[i + 1].textContent)) ? '' : 'none');
任何帮助将不胜感激。
谢谢 :)
解决方案
推荐阅读
- sql-server - 如何在 SQL Server 的服务器审计上添加多个过滤器?
- istio - 通过 ISTIO side car 减少内存使用
- sass - 基于类的变量值
- android - 结合 RxJava Observables、SharedPreferences 和 MVP
- javascript - 单击链接时使用 js 打开带有悬停和关闭菜单的下拉菜单
- javafx - Fitting rotated ImageView into Application Window / Scene
- python-2.7 - 使警告崩溃python脚本
- html - 使用 VBA 获取嵌套表和 Div 中的值
- python - Python 变量名
- javascript - 检测 URL 中的特定哈希