Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

101
Vistas
How to loop through a JSON with EJS while being able to style each item separately

I am trying to loop through a JSON file while using EJS and style each object like a card, but it keeps coming out looking like a child element inside each object looped through before it.

Here is my current EJS code

<section class="job-list">

    <% if (job.length > 0) { %>
        <div class="grid">
            <%for(var i = 0; i < job.length; i++){ %> 
                <article class="card listing-item">
                    <header class="card__header">
                        <img src="<%= job[i].logo %>" alt="">

                    </header>
                    <div class="card__content">
                        <div class="card_content_top">
                            <p class="position_postedAt"><%= job[i].postedAt %></p>
                            <p class="position_contract"><%= job[i].contract %></p>
                        </div>
                        <div class="card_content_bottom">
                            <h1 class="position__position"><%= job[i].position %></h1>
                            <h3 class="position__company">$<%= job[i].company %></h3>
                            <p class="position__location"><%= job[i].location %></p>

                        </div>

                    </div>
                    
            <% } %>        
        </div>
    <% } else { %>
        <h1>No Jobs found today!</h1>    
        <% } %>

</section>

I am currently getting this:

current output

while trying to make it look like seperate cards:

items as seperate cards

I have tried playing around with using a grid with the grid class and the listing-item class, but it keeps styling them inside the others.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I think that you are missing the closing tag </article> for article html element.

Article HTML tag: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/article

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda