Hiho,
I have some divs of class ‘item’ and a input field to search them.
The following function is fired from ‘update’ event on input field:
function filterItems(ss) {
document.querySelectorAll(".item").forEach(ele => {
if (ele.dataset.name.includes(ss)) {
ele.style.display = 'flex'
} else {
ele.style.display = 'none'
}
})
}
It works fine, but I have problems with CSS
.item {
background-color: red;
}
.item:nth-child(even of :not([display='none'])) {
background-color: green;
}
Any ideas why the selector is not working after filtering out some divs?