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

180
Visualizações
How to add an attribute to an image with a specific class or alt text js/jquery?

I need to add an attribute to specific images by using JS or jQuery, but I can't figure it out.

I'm using WordPress and the images that I want to add the attribute are inside a slider, so I cannot add any class to those images.

I tried to add the attribute that I want by using the container class to find images, but it didn't work.

$('.dce-img > img').attr('rlskip', '1');

This how I want it to be:

<div class="dce-item">
  <figure data-image-ratio="0.5" class="dce-img dce-fit-img">
    <img src="../img/F4D13DA3-5351-4F69-8C33-0A1EF3BFDF67.webp"  alt="Demo_ts_2" rlskip="1"> 
  </figure>
</div>

Can you help me to find a solution please? I have to add the rlskip attribute to the images of the slider here.

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

0

The problem is that $ is not defined. Change $ to jQuery like below:

jQuery('.dce-img > img').attr('rlskip', '1');
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