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

102
Visualizações
How to get data attribute from a DIV and write it to another DIV using jQuery/JS

need to get a data attribute value from a clicked DIV and pass it as data attr for a displaying new DIV:

DIVs to select by click:

<div class="mySlot" data-slot-label="a">A</div>
<div class="mySlot" data-slot-label="b">B</div>
<div class="mySlot" data-slot-label="c">C</div>

The popup DIV that carries over the data-slot value on its as its attr:

<div class="selection" data-slot-label="[The Selected DIV data]"></div>

I'm using this now, but not working:

$('.mySlot').click(function() {
    var mydata = $('.mySlot').data('slot-label');
    $('.selection').data('slot-label',mydata);
});

Cheers

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

0

$('.mySlot').click(function() {
    var mydata = $(this).attr('data-slot-label');
    $('.selection').attr('data-slot-label',mydata);
});

Just use the attr function to add or retrive the data from an element

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