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

Trending Topics

Online now

Members online
909
Guests online
1,492
Total visitors
2,401

Forum statistics

Threads
2,294,873
Posts
29,093,657
Members
1,206,599
Latest member
Gooner_67
Back
Top