I have two separate lists both sitting side by side. How can I refactor the code below to only have one filter function for both lists?
$("input.filterInput").keyup(function() {
filter(this);
});
function filter(element) {
var value = $(element).val();
$(".pdfList > li").each(function (){
if ($(this).text().indexOf(value) > -1) {
$(this).show();
} else {
$(this).hide();
}
});
}
$("input.filterInput2").keyup(function() {
filter2(this);
});
function filter2(element) {
var value = $(element).val();
$(".pdfList2 > li").each(function (){
if ($(this).text().indexOf(value) > -1) {
$(this).show();
} else {
$(this).hide();
}
});
}