What's new

Pa help javascript

ehmjhay99

Forum Veteran
Elite
Joined
Apr 11, 2018
Posts
1,111
Solutions
6
Reaction
4,436
Points
797
Gusto ko po sana pag nag search ako ng artist makita rin, yung ngayon kasi title lang lumalabas pag nag ssearch


Eto po yung code..

window.addEventListener('load', () => {
song.forEach(element =>{
const { img, title, artist, url } = element;

let card = document.createElement('a');
card.href = url;
card.innerHTML = `<img src="${img}">
<div class="artistName">
<h6>${title}</h6>
<p>${artist}</p>
</div>`;
search_bx2.appendChild(card);
});

});
search_box.addEventListener('keyup', () => {
let filter = search_box.value.toUpperCase();
let a = search_bx2.getElementsByTagName('a');
for (let i = 0; i < a.length; i++) {
let b = a.getElementsByClassName('artistName')[0];
let c = b.getElementsByTagName('h6')[0];

let TextValue = c.textContent || c.innerText;
if (TextValue.toUpperCase().indexOf(filter) > -1) {
a.style.display = "";
search_bx2.style.visibility = "visible";
search_bx2.style.opacity = 1;
} else {
a.style.display = "none";
}
if (search_box.value == 0) {
search_bx2.style.visibility = "hidden";
search_bx2.style.opacity = 0;
}
}
});
 

Similar threads

Back
Top