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

134
Visualizações
How to get the properties when a slide is clicked in swiperjs without jquery

I am trying to get the values of a specific card when it is clicked in swiperJS but am not finding in the documentation if it is possible to do so.

Hoping to not resort to wrapping each slide in a label and input button.

My code here:

                    <Swiper
                        slidesPerView={'auto'}
                        spaceBetween={200}
                        centeredSlides={true}
                        pagination={{
                            "clickable": true
                        }}>
                        {Cards.map((card, idx) => {
                            return (
                                <div className="row" style={{ display: 'inline-block' }}>
                                    <div className="col-12 swiper-container">
                                        <SwiperSlide>
                                            <Cards
                                                number={card.number}
                                                name={card.name}
                                                expiry={card.expiry}
                                                cvc={card.cvc}
                                            // focused={focus}
                                            />
                                        </SwiperSlide>
                                    </div>
                                </div>
                            )
                        })}
                    </Swiper>

Is it possible to do so?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Looking at swiper's react source code it seems like SwiperSlide renders by default into a div node . This node can receive a onClick prop, which should execute whatever function you want. That would look something like this:

<SwiperSlide onClick={()=> console.log(card.name)}>
  // ...
</SwiperSlide>

If for some reason that doesn't work either, consider adding the onClick to a div already wrapping the slide (for example div.col-12.swiper-container)

about 4 years ago · Juan Pablo Isaza Relatório
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