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

318
Visualizações
How can add existing name used attr()

I want to change attr('src', 'imagename').

But Preserving the existing name.

<image src="abc">
<jquery>
 $('image).attr('src','' )  -> abcde
 and just add existing abc + de

How can I solve this problem?

thanks :)

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

0

The element name is img not image. Here is one way of doing this:

$('img').attr('src', function(_, currentValue) {
    return currentValue + 'de';
});

Note that this affects all elements in the jQuery collection, i.e. this adds the "de" to all img elements' src attribute.

about 4 years ago · Juan Pablo Isaza Relatório

0

  1. the actual element is <img> not <image>

  2. Use the same code to get src first and then replace the value by adding an extra string to it.

Running example:

$('img').attr('src', $('img').attr('src')+'de');
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<img src="abc">

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