Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

104
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!