Loldawg icon

Untitled

Loldawg | PRO | 09/30/17 04:53:53 PM UTC | 0 ⭐ | 255 👁️ | Never ⏰ | []
JavaScript |

680 B

|

None

|

0 👍

/

0 👎

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