Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

101
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda