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

Online now

Members online
508
Guests online
1,286
Total visitors
1,794

Forum statistics

Threads
2,277,853
Posts
28,979,277
Members
1,229,112
Latest member
rosearugay
Back
Top