var searchbar = document.getElementById('search');
searchbar.addEventListener("keyup", searchForCar);
function searchForCar(){
var currentinput = this.value;
var searchquery = document.getElementById('cars').querySelectorAll("[data-carname~=" + CSS.escape(currentinput) + "]");
for (var index = 0; index < searchquery.length; index++) {
var found = searchquery[index].id;
console.log(found);
var others = document.querySelectorAll(':not(#' + found + ')');
for (var i = 0; i < others.length; i++){
var test = others[i];
test.classList.toggle("fade");
// this.classList.toggle("fade");
// console.log(others[i].id);
console.log(others[i].id);
}
}
}
Comments