I’m having trouble linking my filtered movies to styling.
const searchlist = document.getElementById('search-list'); {
//looping through db and constructing elements
for (let index = 0; index < Movies.length; index++) {
let item = Movies[index]
//constructing cards elemnets
const card = document.createElement('div'); {
card.className = 'Media-Card';
searchlist.appendChild(card)
const cover = document.createElement('img');{
cover.src = item.poster
cover.className = 'Poster';
card.appendChild(cover)
}
const header = document.createElement('h1'); {
const textNode = document.createTextNode("")
textNode.nodeValue = item.title
header.appendChild(textNode);
header.className = 'Media-Card-Header';
card.appendChild(header)
}
}
}
I want to only display movies that match the users input string.
//Filter through db
search.onkeydown = function filterMovies(e) {
const searchstring = e.target.value.toLowerCase(); {
}
const filteredMovies = Movies.filter((item) => {
return (item.title.toLowerCase().includes(searchstring));
})
}
Next, I wish to link a objects page property to the submitted keyword. This should result in a page redirect to its html page.
so far, I have looped through each array object and created its html/css elements. I am having trouble with code organization.