【发布时间】:2023-03-28 14:25:01
【问题描述】:
我正在根据第一个字符过滤数据,但是当用户单击全部时,我想显示所有数据,但是一旦我根据字符过滤了数据,我就无法将其重置为全部。
我想允许用户根据字母用户选择过滤数据,当用户点击所有用户应该能够再次看到所有项目。
我的代码:
$('.myFilters li').on("click", function() {
if($(this).text() == "all"){
$(this).show();
return ;
}
var letter = $(this).text()[0];
$('#mycatouter div').each(function() {
letter=letter.toUpperCase();
if ($(this).text()[0] == letter) {
$(this).show();
} else {
$(this).hide();
}
});
});
【问题讨论】:
-
插入你的html和css
标签: javascript jquery filtering