gamer
gamer

Reputation: 11

How to display the images (using posters from OMDb API) using html and only JavaScript in grid inside a for loop?

I have been trying to display the trying to print the posters using foreach() loop, It displays only in the single column, use of class is not giving correct output instead it is making column inside one another because of the loop, how can I display the images in grid layer

Below is my code,

movies.forEach(movie => {
  output += `
    <div class="block">
      <div>
         <a onclick="movieSelected('${movie.imdbID}')" href="#">
           <img src="${movie.Poster}" class="box-1 border">
         </a>
       </div>
    <div>`
})

and display the html using the innerhtml()

Upvotes: 0

Views: 1096

Answers (0)

Related Questions