🔒 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
  • 289
    Views
  • 1
    Participants
Last reply from:
ehmjhay99

Trending Topics

Online now

Members online
1,274
Guests online
4,070
Total visitors
5,344

Forum statistics

Threads
2,308,763
Posts
29,187,176
Members
1,191,196
Latest member
madrid22
Back
Top