Javascript 使用JQuery筛选表单元格
您好,我需要有关筛选表格单元格的帮助。我可以通过从下拉菜单中选择一个值来过滤表格单元格。但是,当我尝试选择一个日期,然后搜索包含该日期的值时,它不起作用 当前代码:Javascript 使用JQuery筛选表单元格,javascript,jquery,html,Javascript,Jquery,Html,您好,我需要有关筛选表格单元格的帮助。我可以通过从下拉菜单中选择一个值来过滤表格单元格。但是,当我尝试选择一个日期,然后搜索包含该日期的值时,它不起作用 当前代码: $('#LoggingDatePicker').change(function () { //$("#LoggingInputs option:first").attr('selected','selected'); //$('#LoggingSearch').val('')
$('#LoggingDatePicker').change(function () {
//$("#LoggingInputs option:first").attr('selected','selected');
//$('#LoggingSearch').val('');
var value = this.value.toLowerCase().trim();
console.log(value);
$("table tr").each(function (index) {
if (!index) return;
$(this).find("td").each(function () {
var id = $(this).text().toLowerCase().trim();
var not_found = (id.indexOf(value) == -1);
$(this).closest('tr').toggle(!not_found);
return not_found;
});
});
});
//Displays logging with the specific date
//Displays logging with the specific logging level which is selected
$("#LoggingInputs").change(function() {
//$('#LoggingDatePicker').val('');
//$('#LoggingSearch').val('');
var value = this.value.toLowerCase().trim();
$("table tr").each(function (index) {
if (!index) return;
$(this).find("td").each(function () {
var id = $(this).text().toLowerCase().trim();
var not_found = (id.indexOf(value) == -1);
$(this).closest('tr').toggle(!not_found);
return not_found;
});
});
});
});
如上图所示,我已经选择了调试和日期,但当它被选择为“2014-12-17”时,它仍然显示“2014-12-18”和“2014-12-19”
如何筛选特定日期的值,然后对该日期进行额外搜索
下面是一个用于测试的演示:
在我用$this.parent'tr替换了$this.tr'之后,它对我来说很好用。为了更好的测试,你能发布一个提琴吗?.parent on。只有在查看了html@Ferret但是,当您选择另一个日志级别,然后返回选择调试时,这是有效的。这又回到了我遇到的问题,我们只能在没有演示的情况下猜测。试图在选择其他日志级别时触发输入更改?@Chris:这一个添加了自由形式搜索: