🔒 Closed Pa help javascript

Status
Not open for further replies.

ehmjhay99

Forum Veteran
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;
}
}
});
 
Status
Not open for further replies.

About this Thread

  • 0
    Replies
  • 292
    Views
  • 1
    Participants
Last reply from:
ehmjhay99

Trending Topics

Online now

Members online
719
Guests online
2,650
Total visitors
3,369

Forum statistics

Threads
2,331,984
Posts
29,261,667
Members
1,145,974
Latest member
jofre43
Back
Top