Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

183
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda