You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
915 B
27 lines
915 B
const pokemoni = [
|
|
"Pikachu", "Bulbasaur","Charmander","Squirtle",
|
|
"Mewtwo","Eevee","Snorlax","Dragonite",
|
|
"Gengar","Lucario","Arcanine","Psyduck",
|
|
"Meowth","Onix"
|
|
]
|
|
|
|
const input = document.getElementById("search")
|
|
const list = document.getElementById("results")
|
|
|
|
input.addEventListener("input", () => {
|
|
const value = input.value.toLowerCase().trim();
|
|
|
|
if( value === ""){
|
|
list.innerHTML= '<li class="list-group-item text-muted">Zatím nic nehledáš...</li>';
|
|
return
|
|
}
|
|
const filtered = pokemoni.filter(p => p.toLowerCase().includes(value));
|
|
|
|
if (filtered.length > 0){
|
|
list.innerHTML = filtered
|
|
.map(p => `<li class="list-group-item list-group-item-action">${p}</li>`)
|
|
.join("");
|
|
} else {
|
|
list.innerHTML = '<li class="list-group-item list-group-item-danger">Žádný pokemon nenalezen :( </li>';
|
|
}
|
|
})
|