05. Table - Search Engine - JS Advanced DOM Introduction
// Кода отдолу СИ РАБОТИ (в Mozilla) 16/100 в judge - HELP
function solve() {
document.querySelector('#searchBtn').addEventListener('click', onClick);
function onClick() {
let search = document.getElementById("searchField").value
let data = document.getElementsByTagName("table")[0].rows
if (search){
for (i=1;i<data.length;i++){
document.getElementsByTagName("table")[0].rows[i].removeAttribute("class")
let tr = data[i]
let td = tr.children
for(each of td){
if(each.innerHTML.includes(search)){
tr.classList.add("select")
}
}
}
document.getElementById("searchField").value = ""
}else{
let data = document.getElementsByTagName("table")[0].rows
for (i=1;i<data.length;i++){
document.getElementsByTagName("table")[0].rows[i].removeAttribute("class")
}
}
}
}
Елегантно! Благодаря!