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

172
Views
Choosing the first post (loop)

I have a loop in Blogger that selects the last 5 posts. I want to apply different css to the first of these last 5 posts and different css to the other 4 posts.

Current script applies same css to all of them, how can i keep first post separate.

Here is the script;

let postCount = 5;
    
     function funcrct(JSON) {
            const POSTS = JSON.feed.entry;
            let postTitle, postUrl = "";
            let rpc = document.querySelector(".postList");
            for (let i = 0; i < postCount; i++) {
                POSTS[i].link.forEach((el, i) => {
                    if (el.rel === "alternate") {
                        postTitle = el.title;
                        postUrl = el.href;
                    }
                })
        
                let thumbnail = POSTS[i].content.$t.match(/(http)?s?:?(\/\/[^"']*\.(?:webp))/)[0];
        
                rpc.innerHTML += `<li>
        <a href="${postUrl}"><figure>       
        <img src="${thumbnail}" alt="${postTitle}"/>
        <figcaption>
        ${postTitle}</figcaption></figure></a>
        </li>`;
            }
        }
        
        var url = document.location.origin;
        var fsrc = document.createElement("script");
        fsrc.src = `${url}/feeds/posts/default?alt=json-in-script&start-index=1&max-results=${postCount}&callback=funcrct`;
        
        
        document.body.appendChild(fsrc);

Html

<div><ul class='postList'></ul></div>
about 4 years ago · Juan Pablo Isaza
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!